2002-09-06 Ravi Pratap <ravi@ximian.com>
authorRavi Pratap M <ravi@mono-cvs.ximian.com>
Sun, 8 Sep 2002 04:49:30 +0000 (04:49 -0000)
committerRavi Pratap M <ravi@mono-cvs.ximian.com>
Sun, 8 Sep 2002 04:49:30 +0000 (04:49 -0000)
* attribute.cs : Fix incorrect code which relied on catching
a NullReferenceException to detect a null being passed in
where an object was expected.

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

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

index 0618431293c2f9ccd35431cdb7ded63d72a418b3..73253ffbfa38b2675e047f659fbe60d8c0c80cb8 100755 (executable)
@@ -1,3 +1,9 @@
+2002-09-06  Ravi Pratap  <ravi@ximian.com>
+
+       * attribute.cs : Fix incorrect code which relied on catching
+       a NullReferenceException to detect a null being passed in
+       where an object was expected.
+
 2002-09-06  Miguel de Icaza  <miguel@ximian.com>
 
        * expression.cs (Cast): Simplified by using ResolveType instead of
index 9baa91a5aaf7af1fbf00a03d527cc2a0d1d9e4b7..c06c11e418dcec82b0652fae1c58847e2110d534 100644 (file)
@@ -278,6 +278,23 @@ namespace Mono.CSharp {
                                Error_AttributeConstructorMismatch (Location);\r
                                return null;\r
                        }\r
+\r
+                       //\r
+                       // Now we perform some checks on the positional args as they\r
+                       // cannot be null for a constructor which expects a parameter\r
+                       // of type object\r
+                       //\r
+\r
+                       ParameterData pd = Invocation.GetParameterData (constructor);\r
+\r
+                       for (int j = 0; j < pos_args.Count; ++j) {\r
+                               Argument a = (Argument) pos_args [j];\r
+                               \r
+                               if (a.Expr is NullLiteral && pd.ParameterType (j) == TypeManager.object_type) {\r
+                                       Error_AttributeArgumentNotValid ();\r
+                                       return null;\r
+                               }\r
+                       }\r
                        \r
                        PropertyInfo [] prop_info_arr = new PropertyInfo [prop_infos.Count];\r
                        FieldInfo [] field_info_arr = new FieldInfo [field_infos.Count];\r
@@ -295,8 +312,11 @@ namespace Mono.CSharp {
                                        (ConstructorInfo) constructor, pos_values,\r
                                        prop_info_arr, prop_values_arr,\r
                                        field_info_arr, field_values_arr); \r
+\r
                        } catch (NullReferenceException) {\r
-                               Error_AttributeArgumentNotValid ();\r
+                               // \r
+                               // Don't know what to do here\r
+                               //\r
                        } catch {\r
                                //\r
                                // Sample:\r