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).
" 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);
\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
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
\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
\r
} else {\r
if (!CheckAttribute (a, kind)) {\r
- error592 (a, loc);\r
+ Error_AttributeNotValidForElement (a, loc);\r
return;\r
}\r
}\r
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;