protected override Expression DoResolve(ResolveContext ec) { if (Arguments == null || Arguments.Count != 1) { ec.Report.Error(149, loc, "Method name expected"); return(null); } Argument a = Arguments [0]; if (!a.ResolveMethodGroup(ec)) { return(null); } Expression e = a.Expr; AnonymousMethodExpression ame = e as AnonymousMethodExpression; if (ame != null && ec.Module.Compiler.Settings.Version != LanguageVersion.ISO_1) { e = ame.Compatible(ec, type); if (e == null) { return(null); } return(e.Resolve(ec)); } method_group = e as MethodGroupExpr; if (method_group == null) { if (e.Type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { e = Convert.ImplicitConversionRequired(ec, e, type, loc); } else if (!e.Type.IsDelegate) { e.Error_UnexpectedKind(ec, ResolveFlags.MethodGroup | ResolveFlags.Type, loc); return(null); } // // An argument is not a method but another delegate // method_group = new MethodGroupExpr(Delegate.GetInvokeMethod(e.Type), e.Type, loc); method_group.InstanceExpression = e; } return(base.DoResolve(ec)); }
public override Expression DoResolve(ResolveContext ec) { if (Arguments == null || Arguments.Count != 1) { ec.Report.Error(149, loc, "Method name expected"); return(null); } Argument a = Arguments [0]; if (!a.ResolveMethodGroup(ec)) { return(null); } Expression e = a.Expr; AnonymousMethodExpression ame = e as AnonymousMethodExpression; if (ame != null && RootContext.Version != LanguageVersion.ISO_1) { e = ame.Compatible(ec, type); if (e == null) { return(null); } return(e.Resolve(ec)); } method_group = e as MethodGroupExpr; if (method_group == null) { if (!TypeManager.IsDelegateType(e.Type)) { e.Error_UnexpectedKind(ec, ResolveFlags.MethodGroup | ResolveFlags.Type, loc); return(null); } // // An argument is not a method but another delegate // delegate_instance_expression = e; method_group = new MethodGroupExpr(new MemberInfo [] { Delegate.GetInvokeMethod(ec.Compiler, ec.CurrentType, e.Type) }, e.Type, loc); } return(base.DoResolve(ec)); }