// TODO: When in probing mode do IsApplicable only and when called again do VerifyArguments for full error reporting
best_candidate = r.ResolveMember<MethodSpec> (ec, ref args);
- if (best_candidate == null)
- return r.BestCandidateIsDynamic ? this : null;
+ if (best_candidate == null) {
+ if (!r.BestCandidateIsDynamic)
+ return null;
+
+ if (simple_name != null && ec.IsStatic)
+ InstanceExpression = ProbeIdenticalTypeName (ec, InstanceExpression, simple_name);
+
+ return this;
+ }
// Overload resolver had to create a new method group, all checks bellow have already been executed
if (r.BestCandidateNewMethodGroup != null)
if (best_candidate.IsExtensionMethod && args[0].Expr == InstanceExpression) {
InstanceExpression = null;
} else {
- if (best_candidate.IsStatic && simple_name != null) {
+ if (simple_name != null && best_candidate.IsStatic) {
InstanceExpression = ProbeIdenticalTypeName (ec, InstanceExpression, simple_name);
}
MemberAccess ma = expr as MemberAccess;
if (ma != null) {
- var left_type = ma.LeftExpression as TypeExpr;
+ var inst = mg.InstanceExpression;
+ var left_type = inst as TypeExpr;
if (left_type != null) {
args.Insert (0, new Argument (new TypeOf (left_type.Type, loc).Resolve (ec), Argument.AType.DynamicTypeName));
- } else {
+ } else if (inst != null) {
//
// Any value type has to be pass as by-ref to get back the same
// instance on which the member was called
//
- var mod = ma.LeftExpression is IMemoryLocation && TypeSpec.IsValueType (ma.LeftExpression.Type) ?
+ var mod = inst is IMemoryLocation && TypeSpec.IsValueType (inst.Type) ?
Argument.AType.Ref : Argument.AType.None;
- args.Insert (0, new Argument (ma.LeftExpression.Resolve (ec), mod));
+ args.Insert (0, new Argument (inst.Resolve (ec), mod));
}
} else { // is SimpleName
if (ec.IsStatic) {
{
public D D { get; private set; }
public string Value { get; private set; }
+ public Foo Foo { get; set; }
public int Test ()
{
return D.Foo (d.Value);
}
+ public static int Test2 (dynamic d)
+ {
+ return Foo.Method(d);
+ }
+
public static int Main ()
{
var c = new C ();
if (c.Test () != 1)
return 1;
+
+ if (C.Test2 ("s") != 1)
+ return 2;
return 0;
}
return 1;
}
}
+
+public class Foo
+{
+ public static int Method (string s)
+ {
+ return 1;
+ }
+}
<size>253</size>\r
</method>\r
<method name="Int32 Main()" attrs="150">\r
- <size>35</size>\r
+ <size>58</size>\r
</method>\r
<method name="Void .ctor()" attrs="6278">\r
<size>7</size>\r
<size>10</size>\r
</method>\r
</type>\r
+ <type name="C">\r
+ <method name="Foo get_Foo()" attrs="2182">\r
+ <size>14</size>\r
+ </method>\r
+ <method name="Void set_Foo(Foo)" attrs="2182">\r
+ <size>8</size>\r
+ </method>\r
+ <method name="Int32 Test2(System.Object)" attrs="150">\r
+ <size>175</size>\r
+ </method>\r
+ </type>\r
+ <type name="Foo">\r
+ <method name="Int32 Method(System.String)" attrs="150">\r
+ <size>10</size>\r
+ </method>\r
+ <method name="Void .ctor()" attrs="6278">\r
+ <size>7</size>\r
+ </method>\r
+ </type>\r
</test>\r
<test name="dtest-057.cs">\r
<type name="Program">\r