[mcs] Handling CreateStandardLiftedOperatorsTable for corlib without nullable type
authorMarek Safar <marek.safar@gmail.com>
Mon, 14 Jul 2014 12:45:13 +0000 (14:45 +0200)
committerMarek Safar <marek.safar@gmail.com>
Mon, 14 Jul 2014 12:45:13 +0000 (14:45 +0200)
mcs/mcs/expression.cs

index 271590c40e242d99c0c506e74704ba77d2bc46c0..3c454aa1f14c2c5964aa3c66ceaa50081c75bb87 100644 (file)
@@ -3171,11 +3171,21 @@ namespace Mono.CSharp
                }
                public static PredefinedOperator[] CreateStandardLiftedOperatorsTable (ModuleContainer module)
                {
+                       var types = module.Compiler.BuiltinTypes;
+
+                       //
+                       // Not strictly lifted but need to be in second group otherwise expressions like
+                       // int + null would resolve to +(object, string) instead of +(int?, int?)
+                       //
+                       var string_operators = new [] {
+                               new PredefinedStringOperator (types.String, types.Object, Operator.AdditionMask, types.String),
+                               new PredefinedStringOperator (types.Object, types.String, Operator.AdditionMask, types.String),
+                       };
+
                        var nullable = module.PredefinedTypes.Nullable.TypeSpec;
                        if (nullable == null)
-                               return new PredefinedOperator [0];
+                               return string_operators;
 
-                       var types = module.Compiler.BuiltinTypes;
                        var bool_type = types.Bool;
 
                        var nullable_bool = nullable.MakeGenericType (module, new[] { bool_type });
@@ -3210,13 +3220,8 @@ namespace Mono.CSharp
                                new PredefinedOperator (nullable_long, nullable_int, Operator.NullableMask | Operator.ShiftMask),
                                new PredefinedOperator (nullable_ulong, nullable_int, Operator.NullableMask | Operator.ShiftMask),
 
-                               //
-                               // Not strictly lifted but need to be in second group otherwise expressions like
-                               // int + null would resolve to +(object, string) instead of +(int?, int?)
-                               //
-                               new PredefinedStringOperator (types.String, types.Object, Operator.AdditionMask, types.String),
-                               new PredefinedStringOperator (types.Object, types.String, Operator.AdditionMask, types.String),
-
+                               string_operators [0],
+                               string_operators [1]
                        };
                }