this.argumentInfo = argumentInfo.ToReadOnly ();
}
- public override bool Equals (object obj)
- {
- var other = obj as CSharpInvokeBinder;
- return other != null && other.flags == flags && other.callingContext == callingContext &&
- other.argumentInfo.SequenceEqual (argumentInfo);
- }
-
- public override int GetHashCode ()
- {
- return Extensions.HashCode (
- flags.GetHashCode (),
- callingContext.GetHashCode (),
- argumentInfo.GetHashCode ());
- }
-
public override DynamicMetaObject FallbackInvoke (DynamicMetaObject target, DynamicMetaObject[] args, DynamicMetaObject errorSuggestion)
{
- var expr = CSharpBinder.CreateCompilerExpression (argumentInfo [0], target);
- var c_args = CSharpBinder.CreateCompilerArguments (argumentInfo.Skip (1), args);
+ var ctx = DynamicContext.Create ();
+ var expr = ctx.CreateCompilerExpression (argumentInfo [0], target);
+ var c_args = ctx.CreateCompilerArguments (argumentInfo.Skip (1), args);
expr = new Compiler.Invocation (expr, c_args);
- var restrictions = CSharpBinder.CreateRestrictionsOnTarget (target).Merge (
- CSharpBinder.CreateRestrictionsOnTarget (args));
+ if ((flags & CSharpBinderFlags.ResultDiscarded) == 0)
+ expr = new Compiler.Cast (new Compiler.TypeExpression (ctx.ImportType (ReturnType), Compiler.Location.Null), expr, Compiler.Location.Null);
+ else
+ expr = new Compiler.DynamicResultCast (ctx.ImportType (ReturnType), expr);
+
+ var binder = new CSharpBinder (this, expr, errorSuggestion);
+ binder.AddRestrictions (target);
+ binder.AddRestrictions (args);
- return CSharpBinder.Bind (target, expr, callingContext, restrictions, errorSuggestion);
+ return binder.Bind (ctx, callingContext);
}
}
}