Reorder logic in DMO type conversion
authorMarek Safar <marek.safar@gmail.com>
Wed, 10 Nov 2010 09:04:48 +0000 (09:04 +0000)
committerMarek Safar <marek.safar@gmail.com>
Wed, 10 Nov 2010 09:05:44 +0000 (09:05 +0000)
mcs/class/Microsoft.CSharp/Microsoft.CSharp.RuntimeBinder/CSharpBinder.cs

index 061a8afea866275c69a16a938f8d2996cd94cb74..4a093a38ac4df55c2ed044e59c034b25145a7e5c 100644 (file)
@@ -201,18 +201,15 @@ namespace Microsoft.CSharp.RuntimeBinder
                //
                public Compiler.Expression CreateCompilerExpression (CSharpArgumentInfo info, DynamicMetaObject value)
                {
-                       if (value.Value == null && (info == null || (info.Flags & (CSharpArgumentInfoFlags.IsOut | CSharpArgumentInfoFlags.IsRef | CSharpArgumentInfoFlags.UseCompileTimeType)) == 0)) {
-                               if (value.LimitType == typeof (object))
-                                       return new Compiler.NullLiteral (Compiler.Location.Null);
-
-                               return Compiler.Constant.CreateConstantFromValue (ImportType (value.LimitType), null, Compiler.Location.Null);
-                       }
-
                        //
                        // No type details provider, go with runtime type
                        //
-                       if (info == null)
+                       if (info == null) {
+                               if (value.LimitType == typeof (object))
+                                       return new Compiler.NullLiteral (Compiler.Location.Null);
+
                                return new Compiler.RuntimeValueExpression (value, ImportType (value.RuntimeType));
+                       }
 
                        //
                        // Value is known to be a type
@@ -220,6 +217,12 @@ namespace Microsoft.CSharp.RuntimeBinder
                        if ((info.Flags & CSharpArgumentInfoFlags.IsStaticType) != 0)
                                return new Compiler.TypeExpression (ImportType ((Type) value.Value), Compiler.Location.Null);
 
+                       if (value.Value == null &&
+                               (info.Flags & (CSharpArgumentInfoFlags.IsOut | CSharpArgumentInfoFlags.IsRef | CSharpArgumentInfoFlags.UseCompileTimeType)) == 0 &&
+                               value.LimitType == typeof (object)) {
+                               return new Compiler.NullLiteral (Compiler.Location.Null);
+                       }
+
                        //
                        // Use compilation time type when type was known not to be dynamic during compilation
                        //