2008-03-27 Marek Safar <marek.safar@gmail.com>
[mono.git] / mcs / mcs / ecore.cs
index 2beecd12fb30ce15b158b1b40ecd74ee0b8467cc..6beb5fab57d9b4711adb2684915f30f65b17a96f 100644 (file)
@@ -1321,6 +1321,21 @@ namespace Mono.CSharp {
                        if (c != null)
                                return new EmptyConstantCast (c, type);
 
+                       //
+                       // No double conversion required when wrapping nullable types
+                       //
+                       if (TypeManager.IsNullableType (type)) {
+                               EmptyCast empty_cast = child as EmptyCast;
+                               if (empty_cast != null) {
+                                       if (TypeManager.IsNullableTypeOf (empty_cast.type, type))
+                                               throw new InternalErrorException ("Missing nullable underlying type conversion {0} != {1}",
+                                                       TypeManager.CSharpName (empty_cast.type), TypeManager.CSharpName (type));
+
+                                       empty_cast.type = type;
+                                       return empty_cast;
+                               }
+                       }
+                       
                        return new EmptyCast (child, type);
                }
 
@@ -4443,7 +4458,7 @@ namespace Mono.CSharp {
                        //
                        // Fill not provided arguments required by params modifier
                        //
-                       if (params_initializers == null && pd.HasParams && arg_count < pd.Count) {
+                       if (params_initializers == null && pd.HasParams && arg_count < pd.Count && a_idx + 1 == pd.Count) {
                                if (arguments == null)
                                        arguments = new ArrayList (1);