2010-04-12 Marek Safar <marek.safar@gmail.com>
authorMarek Safar <marek.safar@gmail.com>
Mon, 12 Apr 2010 18:38:31 +0000 (18:38 -0000)
committerMarek Safar <marek.safar@gmail.com>
Mon, 12 Apr 2010 18:38:31 +0000 (18:38 -0000)
* expression.cs, attribute.cs, parameter.cs: More attribute type
checks.

svn path=/trunk/mcs/; revision=155258

mcs/mcs/ChangeLog
mcs/mcs/attribute.cs
mcs/mcs/parameter.cs

index 4d093b1bb9daee2a3c12bbd9c154c66f2953659e..64d8c1e0118c6fca08aad5d0a1f7076125c01a71 100644 (file)
@@ -1,6 +1,7 @@
 2010-04-12  Marek Safar  <marek.safar@gmail.com>
 
-       * expression.cs, attribute.cs: More attribute type checks.
+       * expression.cs, attribute.cs, parameter.cs: More attribute type
+       checks.
 
 2010-04-12  Marek Safar  <marek.safar@gmail.com>
 
index a25f825654b06e4ae59108606ff93f76251a4b77..0305d4ad06e1db86ded82f0a06722d18653fbb20 100644 (file)
@@ -750,7 +750,7 @@ namespace Mono.CSharp {
                        if (resolve_error)
                                return null;
 
-                       return ((Constant) PosArguments[0].Expr).GetValue () as Type;
+                       return GetArgumentType ();
                }
 
                public bool CheckTarget ()
@@ -1085,11 +1085,11 @@ namespace Mono.CSharp {
                public Constant GetParameterDefaultValue (out Type type)
                {
                        var expr = PosArguments[0].Expr;
-                       type = expr.Type;
 
                        if (expr is TypeCast)
                                expr = ((TypeCast) expr).Child;
 
+                       type = expr.Type;
                        return expr as Constant;
                }
 
index 96d634e597fd29ba8cc42a396a6c866ebe6b1ba2..9e3d7fddd6a35a284f63a988a389641528b8f429 100644 (file)
@@ -310,13 +310,12 @@ namespace Mono.CSharp {
                                        return;
                                }
 
-                               var val = c.GetValue ();
-                               if (parameter_type == TypeManager.object_type ||
-                                   (val == null && !TypeManager.IsGenericParameter (parameter_type) && TypeManager.IsReferenceType (parameter_type)) ||
-                                   (val != null && TypeManager.TypeToCoreType (val.GetType ()) == parameter_type))
-                                       builder.SetConstant (val);
+                               if (arg_type == parameter_type || parameter_type == TypeManager.object_type || 
+                                       (c.IsNull && TypeManager.IsReferenceType (parameter_type) && !TypeManager.IsGenericParameter (parameter_type)))
+                                       builder.SetConstant (c.GetValue ());
                                else
                                        a.Report.Error (1908, a.Location, "The type of the default value should match the type of the parameter");
+
                                return;
                        }