Maintain only one place with dynamic explicit conversions
[mono.git] / mcs / tests / dtest-003.cs
index 4990121d73a285815cdf6128ceaa5e3582ef7a62..d729de720671cc9d7323ebdeaf61a679d332bae8 100644 (file)
@@ -25,11 +25,10 @@ class AssertDynamicObject : DynamicMetaObject
        DynamicMetaObject GetFakeMetaObject (object value)
        {
                Type t = value == null ? typeof (object) : value.GetType ();
-               var v = Expression.Variable (t);
-               Expression e = Expression.Block (new[] { v }, Expression.Default (t));
+               Expression<Func<object>> et = () => value;
 
                Expression restr = Expression.Constant (true);
-               return new DynamicMetaObject (e, BindingRestrictions.GetExpressionRestriction (restr));
+               return new DynamicMetaObject (Expression.Convert (et.Body, t), BindingRestrictions.GetExpressionRestriction (restr));
        }
 
        public override DynamicMetaObject BindBinaryOperation (BinaryOperationBinder binder, DynamicMetaObject arg)
@@ -217,8 +216,7 @@ class Tester : DynamicObjectMock
                if (values.Count != expected.Length)
                        throw new ApplicationException (name + ": Array length does not match " + values.Count + " != " + expected.Length);
 
-               for (int i = 0; i < expected.Length; i++)
-               {
+               for (int i = 0; i < expected.Length; i++) {
                        Assert (flags.GetValue (expected[i]), flags.GetValue (values[i]), "flags");
                }
        }
@@ -231,7 +229,7 @@ class Tester : DynamicObjectMock
                        Assert (binder.Operation, ExpressionType.Add, "Operation");
                        AssertArgument (binder, new[] {
                            CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.None, null),
-                           CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.LiteralConstant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
+                           CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.Constant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
                                "ArgumentInfo");
 
                        Assert (arg, 1, "arg");
@@ -262,7 +260,7 @@ class Tester : DynamicObjectMock
                        Assert (binder.Operation, ExpressionType.Add, "Operation");
                        AssertArgument (binder, new[] {
                            CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.None, null),
-                           CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.UseCompileTimeType | CSharpArgumentInfoFlags.LiteralConstant, null)      // CSC bug?
+                           CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.UseCompileTimeType, null)
                        }, "ArgumentInfo");
 
                        Assert (arg, Enum.A, "arg");
@@ -292,7 +290,7 @@ class Tester : DynamicObjectMock
                        Assert (binder.Operation, ExpressionType.Add, "Operation");
                        AssertArgument (binder, new[] {
                            CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.None, null),
-                           CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.UseCompileTimeType | CSharpArgumentInfoFlags.LiteralConstant, null) },
+                           CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.UseCompileTimeType | CSharpArgumentInfoFlags.Constant, null) },
                                "ArgumentInfo");
 
                        Assert (arg, 3, "arg");
@@ -300,14 +298,14 @@ class Tester : DynamicObjectMock
 
                d = checked (d + 3);
        }
-       
+
        void BinaryAddChecked_2 (dynamic d, DynamicObjectMock mock)
        {
                mock.BinaryOperation = (binder, arg) => {
                        Assert (binder.Operation, ExpressionType.Add, "Operation");
                        AssertArgument (binder, new[] {
                            CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.None, null),
-                           CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.UseCompileTimeType | CSharpArgumentInfoFlags.LiteralConstant, null) },
+                           CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.UseCompileTimeType | CSharpArgumentInfoFlags.Constant, null) },
                                "ArgumentInfo");
 
                        Assert (arg, 3, "arg");
@@ -317,7 +315,7 @@ class Tester : DynamicObjectMock
                checked {
                        r = () => d + 3;
                }
-               
+
                r ();
        }
 
@@ -327,7 +325,7 @@ class Tester : DynamicObjectMock
                        Assert (binder.Operation, ExpressionType.AddAssign, "Operation");
                        AssertArgument (binder, new[] {
                            CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.None, null),
-                           CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.LiteralConstant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
+                           CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.Constant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
                                "ArgumentInfo");
 
                        Assert (arg, 1, "arg");
@@ -342,7 +340,7 @@ class Tester : DynamicObjectMock
                        Assert (binder.Operation, ExpressionType.AddAssign, "Operation");
                        AssertArgument (binder, new[] {
                            CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.None, null),
-                           CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.LiteralConstant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
+                           CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.Constant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
                                "ArgumentInfo");
 
                        Assert (arg, 1, "arg");
@@ -359,7 +357,7 @@ class Tester : DynamicObjectMock
                        Assert (binder.Operation, ExpressionType.And, "Operation");
                        AssertArgument (binder, new[] {
                            CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.None, null),
-                           CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.LiteralConstant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
+                           CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.Constant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
                                "ArgumentInfo");
 
                        Assert (arg, 1, "arg");
@@ -374,7 +372,7 @@ class Tester : DynamicObjectMock
                        Assert (binder.Operation, ExpressionType.AndAssign, "Operation");
                        AssertArgument (binder, new[] {
                            CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.None, null),
-                           CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.LiteralConstant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
+                           CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.Constant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
                                "ArgumentInfo");
 
                        Assert (arg, 1, "arg");
@@ -389,7 +387,7 @@ class Tester : DynamicObjectMock
                        Assert (binder.Operation, ExpressionType.Divide, "Operation");
                        AssertArgument (binder, new[] {
                            CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.None, null),
-                           CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.LiteralConstant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
+                           CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.Constant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
                                "ArgumentInfo");
 
                        Assert (arg, 1, "arg");
@@ -404,7 +402,7 @@ class Tester : DynamicObjectMock
                        Assert (binder.Operation, ExpressionType.DivideAssign, "Operation");
                        AssertArgument (binder, new[] {
                            CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.None, null),
-                           CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.LiteralConstant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
+                           CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.Constant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
                                "ArgumentInfo");
 
                        Assert (arg, 1, "arg");
@@ -419,7 +417,7 @@ class Tester : DynamicObjectMock
                        Assert (binder.Operation, ExpressionType.Equal, "Operation");
                        AssertArgument (binder, new[] {
                            CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.None, null),
-                           CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.LiteralConstant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
+                           CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.Constant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
                                "ArgumentInfo");
 
                        Assert (arg, 1, "arg");
@@ -434,7 +432,7 @@ class Tester : DynamicObjectMock
                        Assert (binder.Operation, ExpressionType.ExclusiveOr, "Operation");
                        AssertArgument (binder, new[] {
                            CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.None, null),
-                           CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.LiteralConstant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
+                           CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.Constant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
                                "ArgumentInfo");
 
                        Assert (arg, 1, "arg");
@@ -449,7 +447,7 @@ class Tester : DynamicObjectMock
                        Assert (binder.Operation, ExpressionType.ExclusiveOrAssign, "Operation");
                        AssertArgument (binder, new[] {
                            CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.None, null),
-                           CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.LiteralConstant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
+                           CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.Constant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
                                "ArgumentInfo");
 
                        Assert (arg, 1, "arg");
@@ -464,7 +462,7 @@ class Tester : DynamicObjectMock
                        Assert (binder.Operation, ExpressionType.GreaterThan, "Operation");
                        AssertArgument (binder, new[] {
                                CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.None, null),
-                               CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.LiteralConstant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
+                               CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.Constant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
                                "ArgumentInfo");
 
                        Assert (arg, 1, "arg");
@@ -479,7 +477,7 @@ class Tester : DynamicObjectMock
                        Assert (binder.Operation, ExpressionType.GreaterThanOrEqual, "Operation");
                        AssertArgument (binder, new[] {
                            CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.None, null),
-                           CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.LiteralConstant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
+                           CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.Constant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
                                "ArgumentInfo");
 
                        Assert (arg, 1, "arg");
@@ -494,7 +492,7 @@ class Tester : DynamicObjectMock
                        Assert (binder.Operation, ExpressionType.LeftShift, "Operation");
                        AssertArgument (binder, new[] {
                            CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.None, null),
-                           CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.LiteralConstant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
+                           CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.Constant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
                                "ArgumentInfo");
 
                        Assert (arg, 1, "arg");
@@ -509,7 +507,7 @@ class Tester : DynamicObjectMock
                        Assert (binder.Operation, ExpressionType.LeftShiftAssign, "Operation");
                        AssertArgument (binder, new[] {
                            CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.None, null),
-                           CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.LiteralConstant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
+                           CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.Constant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
                                "ArgumentInfo");
 
                        Assert (arg, 1, "arg");
@@ -524,7 +522,7 @@ class Tester : DynamicObjectMock
                        Assert (binder.Operation, ExpressionType.LessThan, "Operation");
                        AssertArgument (binder, new[] {
                            CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.None, null),
-                           CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.LiteralConstant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
+                           CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.Constant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
                                "ArgumentInfo");
 
                        Assert (arg, 1, "arg");
@@ -539,7 +537,7 @@ class Tester : DynamicObjectMock
                        Assert (binder.Operation, ExpressionType.LessThanOrEqual, "Operation");
                        AssertArgument (binder, new[] {
                            CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.None, null),
-                           CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.LiteralConstant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
+                           CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.Constant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
                                "ArgumentInfo");
 
                        Assert (arg, 1, "arg");
@@ -554,7 +552,7 @@ class Tester : DynamicObjectMock
                        Assert (binder.Operation, ExpressionType.Modulo, "Operation");
                        AssertArgument (binder, new[] {
                                CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.None, null),
-                               CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.LiteralConstant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
+                               CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.Constant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
                                "ArgumentInfo");
 
                        Assert (arg, 1, "arg");
@@ -569,7 +567,7 @@ class Tester : DynamicObjectMock
                        Assert (binder.Operation, ExpressionType.ModuloAssign, "Operation");
                        AssertArgument (binder, new[] {
                                CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.None, null),
-                               CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.LiteralConstant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
+                               CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.Constant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
                                "ArgumentInfo");
 
                        Assert (arg, 1, "arg");
@@ -584,7 +582,7 @@ class Tester : DynamicObjectMock
                        Assert (binder.Operation, ExpressionType.Multiply, "Operation");
                        AssertArgument (binder, new[] {
                                CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.None, null),
-                               CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.LiteralConstant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
+                               CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.Constant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
                                "ArgumentInfo");
 
                        Assert (arg, 1, "arg");
@@ -599,7 +597,7 @@ class Tester : DynamicObjectMock
                        Assert (binder.Operation, ExpressionType.MultiplyAssign, "Operation");
                        AssertArgument (binder, new[] {
                                CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.None, null),
-                               CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.LiteralConstant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
+                               CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.Constant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
                                "ArgumentInfo");
 
                        Assert (arg, 1, "arg");
@@ -614,7 +612,7 @@ class Tester : DynamicObjectMock
                        Assert (binder.Operation, ExpressionType.NotEqual, "Operation");
                        AssertArgument (binder, new[] {
                                CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.None, null),
-                               CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.LiteralConstant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
+                               CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.Constant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
                                "ArgumentInfo");
 
                        Assert (arg, 4, "arg");
@@ -629,7 +627,7 @@ class Tester : DynamicObjectMock
                        Assert (binder.Operation, ExpressionType.Or, "Operation");
                        AssertArgument (binder, new[] {
                                CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.None, null),
-                               CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.LiteralConstant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
+                               CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.Constant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
                                "ArgumentInfo");
 
                        Assert (arg, 2, "arg");
@@ -644,7 +642,7 @@ class Tester : DynamicObjectMock
                        Assert (binder.Operation, ExpressionType.OrAssign, "Operation");
                        AssertArgument (binder, new[] {
                                CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.None, null),
-                               CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.LiteralConstant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
+                               CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.Constant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
                                "ArgumentInfo");
 
                        Assert (arg, 2, "arg");
@@ -659,7 +657,7 @@ class Tester : DynamicObjectMock
                        Assert (binder.Operation, ExpressionType.RightShift, "Operation");
                        AssertArgument (binder, new[] {
                                CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.None, null),
-                               CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.LiteralConstant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
+                               CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.Constant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
                                "ArgumentInfo");
 
                        Assert (arg, 1, "arg");
@@ -674,7 +672,7 @@ class Tester : DynamicObjectMock
                        Assert (binder.Operation, ExpressionType.RightShiftAssign, "Operation");
                        AssertArgument (binder, new[] {
                                CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.None, null),
-                               CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.LiteralConstant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
+                               CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.Constant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
                                "ArgumentInfo");
 
                        Assert (arg, 1, "arg");
@@ -689,7 +687,7 @@ class Tester : DynamicObjectMock
                        Assert (binder.Operation, ExpressionType.Subtract, "Operation");
                        AssertArgument (binder, new[] {
                                CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.None, null),
-                               CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.LiteralConstant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
+                               CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.Constant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
                                "ArgumentInfo");
 
                        Assert (arg, 1, "arg");
@@ -704,7 +702,7 @@ class Tester : DynamicObjectMock
                        Assert (binder.Operation, ExpressionType.SubtractAssign, "Operation");
                        AssertArgument (binder, new[] {
                                CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.None, null),
-                               CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.LiteralConstant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
+                               CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.Constant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
                                "ArgumentInfo");
 
                        Assert (arg, 1, "arg");
@@ -729,10 +727,10 @@ class Tester : DynamicObjectMock
                mock.ConvertOperation = (binder) => {
                        Assert (binder.Explicit, false, "Explicit");
                        Assert (binder.Type, typeof (int), "Type");
-                       return 2;
+                       return 1;
                };
 
-               object[] o = new object [2];
+               object[] o = new object[2];
                d = o[d];
        }
 
@@ -745,7 +743,7 @@ class Tester : DynamicObjectMock
                        return (byte) 2;
                };
 
-               object b = checked((byte) d);
+               object b = checked ((byte) d);
        }
 
        void Convert_4 (dynamic d, DynamicObjectMock mock)
@@ -759,6 +757,20 @@ class Tester : DynamicObjectMock
                var g = new int[d];
        }
 
+       void Convert_5 (dynamic d, DynamicObjectMock mock)
+       {
+               int counter = 0;
+               mock.ConvertOperation = (binder) => {
+                       Assert (binder.Explicit, false, "Explicit");
+                       Assert (binder.Type, typeof (System.Collections.IEnumerable), "Type");
+                       return new object[] { 1 };
+               };
+
+               foreach (int v in d) {
+//                     Console.WriteLine (v);
+               }
+       }
+
        void GetIndex_1 (dynamic d, DynamicObjectMock mock)
        {
                mock.GetIndexOperation = (binder, args) => {
@@ -766,13 +778,13 @@ class Tester : DynamicObjectMock
 //                     Assert (binder.CallingContext, typeof (Tester), "CallingContext");
                        AssertArgument (binder, new[] {
                                CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.None, null),
-                               CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.LiteralConstant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
+                               CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.Constant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
                                "ArgumentInfo");
 
-                       Assert ((IList<object>)args, new object[] { 0 }, "args");
+                       Assert ((IList<object>) args, new object[] { 0 }, "args");
                };
 
-               var o = d [0];
+               var o = d[0];
        }
 
        void GetIndex_2 (dynamic d, DynamicObjectMock mock)
@@ -782,7 +794,7 @@ class Tester : DynamicObjectMock
 //                     Assert (binder.CallingContext, typeof (Tester), "CallingContext");
                        AssertArgument (binder, new[] {
                                CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.None, null),
-                               CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.LiteralConstant | CSharpArgumentInfoFlags.UseCompileTimeType, null),
+                               CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.Constant | CSharpArgumentInfoFlags.UseCompileTimeType, null),
                                CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.UseCompileTimeType, null) },
                        "ArgumentInfo");
 
@@ -830,9 +842,9 @@ class Tester : DynamicObjectMock
 //                     Assert (binder.CallingContext, typeof (Tester), "CallingContext");
                        AssertArgument (binder, new[] {
                                CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.None, null),
-                               CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.LiteralConstant | CSharpArgumentInfoFlags.UseCompileTimeType, null),
-                               CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.LiteralConstant | CSharpArgumentInfoFlags.UseCompileTimeType, null)
-                       },      "ArgumentInfo");
+                               CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.Constant | CSharpArgumentInfoFlags.UseCompileTimeType, null),
+                               CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.Constant | CSharpArgumentInfoFlags.UseCompileTimeType, null)
+                       }, "ArgumentInfo");
 
                        Assert ((IList<object>) args, new object[] { "foo", null }, "args");
                };
@@ -872,13 +884,30 @@ class Tester : DynamicObjectMock
                        AssertArgument (binder, new[] {
                                CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.None, null),
                                CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.UseCompileTimeType, null),
-                               CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.NamedArgument | CSharpArgumentInfoFlags.UseCompileTimeType | CSharpArgumentInfoFlags.LiteralConstant, "name")        // CSC bug?
+                               CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.NamedArgument | CSharpArgumentInfoFlags.UseCompileTimeType, "name")
+                       }, "ArgumentInfo");
+
+                       Assert ((IList<object>) args, new object[] { typeof (bool), -1 }, "args");
+               };
+
+               d (typeof (bool), name: -1);
+       }
+
+       void Invoke_5 (dynamic d, DynamicObjectMock mock)
+       {
+               mock.InvokeOperation = (binder, args) => {
+                       Assert (binder.CallInfo, new CallInfo (2, new string[] { "name" }), "CallInfo");
+                       AssertArgument (binder, new[] {
+                               CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.None, null),
+                               CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.UseCompileTimeType, null),
+                               CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.NamedArgument | CSharpArgumentInfoFlags.UseCompileTimeType, "name")
                        }, "ArgumentInfo");
 
                        Assert ((IList<object>) args, new object[] { typeof (bool), -1 }, "args");
                };
 
-               d (typeof (bool), name:-1);
+               Action<object> a = (i) => { };
+               a (d);
        }
 
        void InvokeMember_1 (dynamic d, DynamicObjectMock mock)
@@ -888,7 +917,7 @@ class Tester : DynamicObjectMock
 //                     Assert (binder.CallingContext, typeof (Tester), "CallingContext");
                        AssertArgument (binder, new[] {
                                CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.None, null),
-                               CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.LiteralConstant | CSharpArgumentInfoFlags.UseCompileTimeType, null)},
+                               CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.Constant | CSharpArgumentInfoFlags.UseCompileTimeType, null)},
                                "ArgumentInfo");
 
 //                     Assert (binder.Flags, CSharpCallFlags.None, "Flags");
@@ -976,7 +1005,7 @@ class Tester : DynamicObjectMock
                        AssertArgument (binder, new[] {
                                CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.UseCompileTimeType, null),
                                CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.None, null),
-                               CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.UseCompileTimeType | CSharpArgumentInfoFlags.LiteralConstant, null),
+                               CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.UseCompileTimeType | CSharpArgumentInfoFlags.Constant, null),
                        }, "ArgumentInfo");
 //                     Assert (binder.Flags, CSharpCallFlags.SimpleNameCall, "Flags");
                        Assert (binder.IgnoreCase, false, "IgnoreCase");
@@ -1013,8 +1042,8 @@ class Tester : DynamicObjectMock
 //                     Assert (binder.CallingContext, typeof (Tester), "CallingContext");
                        AssertArgument (binder, new[] {
                                CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.None, null),
-                               CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.LiteralConstant | CSharpArgumentInfoFlags.UseCompileTimeType, null),
-                               CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.LiteralConstant | CSharpArgumentInfoFlags.UseCompileTimeType, null)},
+                               CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.Constant | CSharpArgumentInfoFlags.UseCompileTimeType, null),
+                               CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.Constant | CSharpArgumentInfoFlags.UseCompileTimeType, null)},
                                "ArgumentInfo");
 
                        Assert ((IList<object>) args, new object[] { 0 }, "args");
@@ -1031,9 +1060,9 @@ class Tester : DynamicObjectMock
 //                     Assert (binder.CallingContext, typeof (Tester), "CallingContext");
                        AssertArgument (binder, new[] {
                                CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.None, null),
-                               CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.LiteralConstant | CSharpArgumentInfoFlags.UseCompileTimeType, null),
+                               CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.Constant | CSharpArgumentInfoFlags.UseCompileTimeType, null),
                                CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.UseCompileTimeType, null),
-                               CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.LiteralConstant | CSharpArgumentInfoFlags.UseCompileTimeType, null)
+                               CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.UseCompileTimeType, null)
                        }, "ArgumentInfo");
 
                        Assert ((IList<object>) args, new object[] { 2, 3 }, "args");
@@ -1072,8 +1101,8 @@ class Tester : DynamicObjectMock
 //                     Assert (binder.CallingContext, typeof (Tester), "CallingContext");
                        AssertArgument (binder, new[] {
                                CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.None, null),
-                               CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.UseCompileTimeType | CSharpArgumentInfoFlags.LiteralConstant, null)  // CSC bug?
-                       },      "ArgumentInfo");
+                               CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.UseCompileTimeType | CSharpArgumentInfoFlags.Constant, null) // CSC bug?
+                       }, "ArgumentInfo");
 
                        Assert (value, d_const, "value");
                };
@@ -1208,7 +1237,7 @@ class Tester : DynamicObjectMock
                        Assert (binder.Operation, ExpressionType.Equal, "Operation");
                        AssertArgument (binder, new[] {
                                CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.None, null),
-                               CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.LiteralConstant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
+                               CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.Constant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
                                "ArgumentInfo");
 
                        Assert (arg, null, "arg");
@@ -1232,7 +1261,7 @@ class Tester : DynamicObjectMock
                        Assert (binder.Operation, ExpressionType.NotEqual, "Operation");
                        AssertArgument (binder, new[] {
                                CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.None, null),
-                               CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.LiteralConstant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
+                               CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.Constant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
                                "ArgumentInfo");
 
                        Assert (arg, null, "arg");
@@ -1256,7 +1285,7 @@ class Tester : DynamicObjectMock
                        Assert (binder.Operation, ExpressionType.And, "Operation");
                        AssertArgument (binder, new[] {
                                CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.None, null),
-                               CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.LiteralConstant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
+                               CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.Constant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
                                "ArgumentInfo");
 
                        Assert (arg, null, "arg");
@@ -1276,7 +1305,7 @@ class Tester : DynamicObjectMock
                        return true;
                };
 
-               object g = d ? 1 :4;
+               object g = d ? 1 : 4;
        }
 
        void UnaryIsTrue_2 (dynamic d, DynamicObjectMock mock)
@@ -1294,7 +1323,7 @@ class Tester : DynamicObjectMock
                        Assert (binder.Operation, ExpressionType.Or, "Operation");
                        AssertArgument (binder, new[] {
                                CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.None, null),
-                               CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.LiteralConstant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
+                               CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.Constant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
                                "ArgumentInfo");
 
                        Assert (arg, null, "arg");
@@ -1302,7 +1331,7 @@ class Tester : DynamicObjectMock
 
                object x = d || null;
        }
-       
+
 #pragma warning restore 168, 169, 219
 
        static bool RunTest (MethodInfo test)
@@ -1310,7 +1339,7 @@ class Tester : DynamicObjectMock
                Console.Write ("Running test {0, -25}", test.Name);
                try {
                        var d = new DynamicObjectMock ();
-                       test.Invoke (new Tester (), new [] { d, d });
+                       test.Invoke (new Tester (), new[] { d, d });
                        if (d.HitCounter < 1)
                                Assert (true, false, "HitCounter");