Merge pull request #1349 from martinjt/MachineKeyProtect
[mono.git] / mcs / class / Microsoft.CSharp / Microsoft.CSharp.RuntimeBinder / CSharpInvokeBinder.cs
index 4450ea4cb6822ca3c9e9a48db64d9c3658ee05f5..1f6b34a070d4b3c0e502216e3bbe32783074f8a7 100644 (file)
@@ -48,31 +48,23 @@ namespace Microsoft.CSharp.RuntimeBinder
                        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);
                }
        }
 }