return false;
}
- TypeManager.CheckTypeVariance (ret_type, Variance.Covariant, this);
+ VarianceDecl.CheckTypeVariance (ret_type, Variance.Covariant, this);
var resolved_rt = new TypeExpression (ret_type, Location);
InvokeBuilder = new Method (this, resolved_rt, MethodModifiers, new MemberName (InvokeMethodName), p, null);
// Don't emit async method for compiler generated delegates (e.g. dynamic site containers)
//
if (!IsCompilerGenerated) {
- DefineAsyncMethods (Parameters.CallingConvention, resolved_rt);
+ DefineAsyncMethods (resolved_rt);
}
return true;
}
- void DefineAsyncMethods (CallingConventions cc, TypeExpression returnType)
+ void DefineAsyncMethods (TypeExpression returnType)
{
var iasync_result = Module.PredefinedTypes.IAsyncResult;
var async_callback = Module.PredefinedTypes.AsyncCallback;
Arguments delegate_arguments = new Arguments (pd.Count);
for (int i = 0; i < pd.Count; ++i) {
Argument.AType atype_modifier;
- switch (pd.FixedParameters [i].ModFlags) {
+ switch (pd.FixedParameters [i].ModFlags & Parameter.Modifier.RefOutMask) {
case Parameter.Modifier.REF:
atype_modifier = Argument.AType.Ref;
break;
}
}
- TypeSpec rt = delegate_method.ReturnType;
+ TypeSpec rt = method_group.BestCandidateReturnType;
if (rt.BuiltinType == BuiltinTypeSpec.Type.Dynamic)
rt = ec.BuiltinTypes.Object;
Error_ConversionFailed (ec, delegate_method, ret_expr);
}
- if (delegate_method.IsConditionallyExcluded (ec, loc)) {
+ if (method_group.IsConditionallyExcluded) {
ec.Report.SymbolRelatedToPreviousError (delegate_method);
MethodOrOperator m = delegate_method.MemberDefinition as MethodOrOperator;
if (m != null && m.IsPartialDefinition) {
//
// Returns true when type is MVAR or has MVAR reference
//
- static bool ContainsMethodTypeParameter (TypeSpec type)
+ public static bool ContainsMethodTypeParameter (TypeSpec type)
{
var tps = type as TypeParameterSpec;
if (tps != null)
return false;
}
+
+ bool HasMvar ()
+ {
+ if (ContainsMethodTypeParameter (type))
+ return false;
+
+ var best = method_group.BestCandidate;
+ if (ContainsMethodTypeParameter (best.DeclaringType))
+ return false;
+
+ if (best.TypeArguments != null) {
+ foreach (var ta in best.TypeArguments) {
+ if (ContainsMethodTypeParameter (ta))
+ return false;
+ }
+ }
+
+ return true;
+ }
protected override Expression DoResolve (ResolveContext ec)
{
var expr = base.DoResolve (ec);
if (expr == null)
- return null;
+ return ErrorExpression.Instance;
if (ec.IsInProbingMode)
return expr;
//
// Cannot easily cache types with MVAR
//
- if (ContainsMethodTypeParameter (type))
- return expr;
-
- if (ContainsMethodTypeParameter (method_group.BestCandidate.DeclaringType))
+ if (!HasMvar ())
return expr;
//
return CreateExpressionFactoryCall (ec, "Invoke", args);
}
+ public override void FlowAnalysis (FlowAnalysisContext fc)
+ {
+ InstanceExpr.FlowAnalysis (fc);
+ if (arguments != null)
+ arguments.FlowAnalysis (fc);
+ }
+
protected override Expression DoResolve (ResolveContext ec)
{
TypeSpec del_type = InstanceExpr.Type;
//
var call = new CallEmitter ();
call.InstanceExpression = InstanceExpr;
- call.EmitPredefined (ec, method, arguments);
+ call.EmitPredefined (ec, method, arguments, loc);
}
public override void EmitStatement (EmitContext ec)