Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/xamarin/NRefactory.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Grunwald <daniel@danielgrunwald.de>2012-07-22 02:40:12 +0400
committerDaniel Grunwald <daniel@danielgrunwald.de>2012-07-22 02:40:12 +0400
commit4513b6e57cd2133f7e57863517ac58244ed0777c (patch)
tree1870a9f0e1ec86906b955b642b0d4cc99b3d2fc7
parent41b777593a08f72dac3d104d090d00d9505bf3ab (diff)
Avoid NullReferenceExceptions now that MethodGroupResolveResult.TargetResult can be null.
-rw-r--r--ICSharpCode.NRefactory.CSharp/Resolver/CSharpResolver.cs8
-rw-r--r--ICSharpCode.NRefactory.CSharp/Resolver/MethodGroupResolveResult.cs2
2 files changed, 5 insertions, 5 deletions
diff --git a/ICSharpCode.NRefactory.CSharp/Resolver/CSharpResolver.cs b/ICSharpCode.NRefactory.CSharp/Resolver/CSharpResolver.cs
index d984d803..20d34852 100644
--- a/ICSharpCode.NRefactory.CSharp/Resolver/CSharpResolver.cs
+++ b/ICSharpCode.NRefactory.CSharp/Resolver/CSharpResolver.cs
@@ -1907,13 +1907,13 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver
if (mgrr != null) {
if (arguments.Any(a => a.Type.Kind == TypeKind.Dynamic)) {
// If we have dynamic arguments, we need to represent the invocation as a dynamic invocation if there is more than one applicable method.
- var or2 = new OverloadResolution(compilation, arguments, argumentNames, mgrr.TypeArguments.ToArray(), conversions);
+ var or2 = CreateOverloadResolution(arguments, argumentNames, mgrr.TypeArguments.ToArray());
var applicableMethods = mgrr.MethodsGroupedByDeclaringType.SelectMany(m => m, (x, m) => new { x.DeclaringType, Method = m }).Where(x => OverloadResolution.IsApplicable(or2.AddCandidate(x.Method))).ToList();
if (applicableMethods.Count > 1) {
ResolveResult actualTarget;
if (applicableMethods.All(x => x.Method.IsStatic) && !(mgrr.TargetResult is TypeResolveResult))
- actualTarget = new TypeResolveResult(mgrr.TargetResult.Type);
+ actualTarget = new TypeResolveResult(mgrr.TargetType);
else
actualTarget = mgrr.TargetResult;
@@ -1930,7 +1930,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver
OverloadResolution or = mgrr.PerformOverloadResolution(compilation, arguments, argumentNames, checkForOverflow: checkForOverflow, conversions: conversions);
if (or.BestCandidate != null) {
if (or.BestCandidate.IsStatic && !or.IsExtensionMethodInvocation && !(mgrr.TargetResult is TypeResolveResult))
- return or.CreateResolveResult(new TypeResolveResult(mgrr.TargetResult.Type));
+ return or.CreateResolveResult(new TypeResolveResult(mgrr.TargetType));
else
return or.CreateResolveResult(mgrr.TargetResult);
} else {
@@ -2081,7 +2081,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver
if (arguments.Any(a => a.Type.Kind == TypeKind.Dynamic)) {
// If we have dynamic arguments, we need to represent the invocation as a dynamic invocation if there is more than one applicable indexer.
- var or2 = new OverloadResolution(compilation, arguments, argumentNames, null, conversions);
+ var or2 = CreateOverloadResolution(arguments, argumentNames, null);
var applicableIndexers = indexers.SelectMany(x => x).Where(m => OverloadResolution.IsApplicable(or2.AddCandidate(m))).ToList();
if (applicableIndexers.Count > 1) {
diff --git a/ICSharpCode.NRefactory.CSharp/Resolver/MethodGroupResolveResult.cs b/ICSharpCode.NRefactory.CSharp/Resolver/MethodGroupResolveResult.cs
index 243be057..39571f29 100644
--- a/ICSharpCode.NRefactory.CSharp/Resolver/MethodGroupResolveResult.cs
+++ b/ICSharpCode.NRefactory.CSharp/Resolver/MethodGroupResolveResult.cs
@@ -105,7 +105,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver
/// Gets the type of the reference to the target object.
/// </summary>
public IType TargetType {
- get { return targetResult.Type; }
+ get { return targetResult != null ? targetResult.Type : SpecialType.UnknownType; }
}
/// <summary>