2002-10-19 Ravi Pratap <ravi@ximian.com>
[mono.git] / mcs / mcs / attribute.cs
index 9baa91a5aaf7af1fbf00a03d527cc2a0d1d9e4b7..5913efcf2cd536d9d78282af65128eb0f8e6b600 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_arg_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