2002-11-16 Martin Baulig <martin@ximian.com>
[mono.git] / mcs / mcs / attribute.cs
index 5a21b1350711acd289fd26f75de5359e43c8b3df..b939cf436ba46b09f46ef580e6a2f015cf3f41a5 100644 (file)
@@ -155,12 +155,12 @@ namespace Mono.CSharp {
                                        return null;\r
 \r
                                e = a.Expr;\r
+\r
                                if (e is Constant) {\r
                                        pos_values [i] = ((Constant) e).GetValue ();\r
                                } else if (e is TypeOf) {\r
                                        pos_values [i] = ((TypeOf) e).TypeArg;\r
                                } else {\r
-                                       Console.WriteLine ("Foo " + e);\r
                                        Error_AttributeArgumentNotValid ();\r
                                        return null;\r
                                }\r
@@ -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,12 +312,13 @@ 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
+                               // \r
+                               // Don't know what to do here\r
+                               //\r
                                Report.Warning (\r
-                                       -23, Location,\r
-                                       "The compiler can not encode this attribute in the Mono runtime\n" +\r
-                                       "\tdue to a known bug in it.  We know about the problem and will\n" +\r
-                                       "\tfix it as soon as possible.");\r
+                                       -100, Location, "NullReferenceException while trying to create attribute. Something's wrong!");\r
                        } catch {\r
                                //\r
                                // Sample:\r