Skip to content
This repository has been archived by the owner on Sep 24, 2020. It is now read-only.

Commit

Permalink
Use specialized method for MethodGroupConversion. #21
Browse files Browse the repository at this point in the history
  • Loading branch information
dgrunwald committed Mar 11, 2012
1 parent a731b93 commit 24d2d19
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ICSharpCode.NRefactory.CSharp/Resolver/Conversions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@ Conversion MethodGroupConversion(ResolveResult resolveResult, IType toType)
}
var or = rr.PerformOverloadResolution(compilation, args, allowExpandingParams: false, conversions: this);
if (or.FoundApplicableCandidate)
return Conversion.MethodGroupConversion((IMethod)or.BestCandidate);
return Conversion.MethodGroupConversion((IMethod)or.GetBestCandidateWithSubstitutedTypeArguments());
else
return Conversion.None;
}
Expand Down
2 changes: 1 addition & 1 deletion ICSharpCode.NRefactory.CSharp/Resolver/TypeInference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ void MakeOutputTypeInference(ResolveResult e, IType t)
allowExtensionMethods: false,
allowExpandingParams: false);
if (or.FoundApplicableCandidate && or.BestCandidateAmbiguousWith == null) {
IType returnType = or.BestCandidate.ReturnType;
IType returnType = or.GetBestCandidateWithSubstitutedTypeArguments().ReturnType;
MakeLowerBoundInference(returnType, m.ReturnType);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
using System;
using System.IO;
using System.Linq;

using ICSharpCode.NRefactory.CSharp.TypeSystem;
using ICSharpCode.NRefactory.Semantics;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.NRefactory.TypeSystem.Implementation;
using NUnit.Framework;

namespace ICSharpCode.NRefactory.CSharp.Resolver
Expand Down Expand Up @@ -343,5 +343,25 @@ class Derived<T> : Base where T : Derived<T>
Assert.IsFalse(rr.IsError);
Assert.AreEqual(0, rr.Member.Parameters.Count);
}

[Test]
public void MethodGroupConversionForGenericMethodHasSpecializedMethod()
{
string program = @"using System;
class TestClass {
void F<T>(T x) {}
public void M() {
System.Action<int> f;
f = $F$;
}
}";
var conversion = GetConversion(program);
Assert.IsTrue(conversion.IsValid);
Assert.IsTrue(conversion.IsMethodGroupConversion);
Assert.IsInstanceOf<SpecializedMethod>(conversion.Method);
Assert.AreEqual(
new[] { "System.Int32" },
((SpecializedMethod)conversion.Method).TypeArguments.Select(t => t.ReflectionName).ToArray());
}
}
}

0 comments on commit 24d2d19

Please sign in to comment.