//
InFieldInitializer = 1 << 8,
- InferReturnType = 1 << 9
+ InferReturnType = 1 << 9,
+
+ InCompoundAssignment = 1 << 10
}
Flags flags;
public bool IsInFieldInitializer {
get { return (flags & Flags.InFieldInitializer) != 0; }
}
+
+ public bool IsInCompoundAssignment {
+ get { return (flags & Flags.InCompoundAssignment) != 0; }
+ }
public FlowBranching CurrentBranching {
get { return current_flow_branching; }
return EventInfo.DeclaringType;
}
}
+
+ void Error_AssignmentEventOnly ()
+ {
+ Report.Error (79, loc, "The event `{0}' can only appear on the left hand side of `+=' or `-=' operator",
+ GetSignatureForError ());
+ }
public override MemberExpr ResolveMemberAccess (EmitContext ec, Expression left, Location loc,
SimpleName original)
if (!ec.IsInObsoleteScope)
mi.CheckObsoleteness (loc);
+ if ((mi.ModFlags & (Modifiers.ABSTRACT | Modifiers.EXTERN)) != 0 && !ec.IsInCompoundAssignment)
+ Error_AssignmentEventOnly ();
+
FieldExpr ml = new FieldExpr (mi.FieldBuilder, loc);
InstanceExpression = null;
return ml.ResolveMemberAccess (ec, left, loc, original);
}
}
+
+ if (left is This && !ec.IsInCompoundAssignment)
+ Error_AssignmentEventOnly ();
return base.ResolveMemberAccess (ec, left, loc, original);
}
public override void Emit (EmitContext ec)
{
- if (InstanceExpression is This)
- Report.Error (79, loc, "The event `{0}' can only appear on the left hand side of += or -=", GetSignatureForError ());
- else
- Report.Error (70, loc, "The event `{0}' can only appear on the left hand side of += or -= "+
- "(except on the defining type)", Name);
+ Report.Error (70, loc, "The event `{0}' can only appear on the left hand side of += or -= "+
+ "(except on the defining type)", GetSignatureForError ());
}
public override string GetSignatureForError ()