2002-05-05 Miguel de Icaza <miguel@ximian.com>
authorMiguel de Icaza <miguel@gnome.org>
Sun, 5 May 2002 17:17:00 +0000 (17:17 -0000)
committerMiguel de Icaza <miguel@gnome.org>
Sun, 5 May 2002 17:17:00 +0000 (17:17 -0000)
* class.cs (TypeContainer.EmitFieldInitializer): Do not typecast
the result of Assign.Resolve as Assign, but rather as ExpressionStatement.

* attribute.cs: Treat indexers and properties as the same in terms
of applying attributes

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

mcs/mcs/ChangeLog
mcs/mcs/assign.cs
mcs/mcs/attribute.cs
mcs/mcs/class.cs

index 5390b3d351df8f09652d783ff12abf3fe59756bb..4c25c1bf62253da84690808c92be2a7515bd5e6d 100755 (executable)
@@ -1,5 +1,11 @@
 2002-05-05  Miguel de Icaza  <miguel@ximian.com>
 
+       * class.cs (TypeContainer.EmitFieldInitializer): Do not typecast
+       the result of Assign.Resolve as Assign, but rather as ExpressionStatement
+
+       * attribute.cs: Treat indexers and properties as the same in terms
+       of applying attributes
+
        * ecore.cs (FindMostEncompassedType): Use statically initialized
        EmptyExpressions()s like we do elsewhere to avoid creating useless
        objects (and we take this out of the tight loop).
index 818618d722754089776d3d889fad5a5e2776f779..3bbdd6bbd8d6609a09c8d4fc57cfc93ed340186c 100755 (executable)
@@ -128,6 +128,9 @@ namespace Mono.CSharp {
                                      " used from within the type '" + ei.DeclaringType + "')");
                }
 
+               //
+               // Will return either `this' or an instance of `New'.
+               //
                public override Expression DoResolve (EmitContext ec)
                {
                        source = source.Resolve (ec);
index 4a113441ce031a5991498b0fce7a816309ffb660..51a60e1dac30120ec3c20be9b07e9a3ea638789e 100644 (file)
@@ -329,7 +329,7 @@ namespace Mono.CSharp {
 \r
                }\r
 \r
-               public static void error592 (Attribute a, Location loc)\r
+               public static void Error_AttributeNotValidForElement (Attribute a, Location loc)\r
                {\r
                        Report.Error (\r
                                592, loc, "Attribute '" + a.Name +\r
@@ -414,7 +414,7 @@ namespace Mono.CSharp {
                                        return true;\r
                                else\r
                                        return false;\r
-                       } else if (element is Property) {\r
+                       } else if (element is Property || element is Indexer) {\r
                                if ((targets & AttributeTargets.Property) != 0)\r
                                        return true;\r
                                else\r
@@ -454,7 +454,8 @@ namespace Mono.CSharp {
 \r
                                        if (!(kind is TypeContainer))\r
                                                if (!CheckAttribute (a, kind)) {\r
-                                                       error592 (a, loc);\r
+                                                               Console.WriteLine ("Kind is: " + kind);\r
+                                                       Error_AttributeNotValidForElement (a, loc);\r
                                                        return;\r
                                                }\r
 \r
@@ -507,7 +508,7 @@ namespace Mono.CSharp {
 \r
                                                } else {\r
                                                        if (!CheckAttribute (a, kind)) {\r
-                                                               error592 (a, loc);\r
+                                                               Error_AttributeNotValidForElement (a, loc);\r
                                                                return;\r
                                                        }\r
                                                }\r
index d8a97c9cf32af67cc953e5fe28f06f1834e0ade4..19eca5fdf34a0585ea1480390fcfa70118c27b4f 100755 (executable)
@@ -498,13 +498,17 @@ namespace Mono.CSharp {
                                Location l = f.Location;
                                FieldExpr fe = new FieldExpr (f.FieldBuilder, l);
                                fe.InstanceExpression = instance_expr;
-                               Assign a = new Assign (fe, e, l);
-                               
-                               a = (Assign) a.Resolve (ec);
+                               Expression a = new Assign (fe, e, l);
+
+                               a = a.Resolve (ec);
                                if (a == null)
                                        return false;
 
-                               a.EmitStatement (ec);
+                               if (a is ExpressionStatement)
+                                       ((ExpressionStatement) a).EmitStatement (ec);
+                               else {
+                                       throw new Exception ("Assign.Resolve returned a non ExpressionStatement");
+                               }
                        }
                        
                        return true;