From f540f8ac339f7e833398c21516dd91dfc9b0dca5 Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Mon, 14 Jul 2014 14:45:13 +0200 Subject: [mcs] Handling CreateStandardLiftedOperatorsTable for corlib without nullable type --- mcs/mcs/expression.cs | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/mcs/mcs/expression.cs b/mcs/mcs/expression.cs index c4c7168483b..6976b97c8b1 100644 --- a/mcs/mcs/expression.cs +++ b/mcs/mcs/expression.cs @@ -3159,11 +3159,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 }); @@ -3198,13 +3208,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] }; } -- cgit v1.2.3