Skip to content

Commit

Permalink
Disallow readonly on events with associated fields
Browse files Browse the repository at this point in the history
  • Loading branch information
RikkiGibson committed Feb 27, 2019
1 parent ee3228a commit 7da2c02
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ protected void CheckModifiersAndType(DiagnosticBag diagnostics)
// A static member '{0}' cannot be marked as override, virtual, or abstract
diagnostics.Add(ErrorCode.ERR_StaticNotVirtual, location, this);
}
else if (IsStatic && IsReadOnly)
else if (IsReadOnly && (IsStatic || HasAssociatedField))
{
// The modifier '{0}' is not valid for this item
diagnostics.Add(ErrorCode.ERR_BadMemberFlag, location, SyntaxFacts.GetText(SyntaxKind.ReadOnlyKeyword));
Expand Down

0 comments on commit 7da2c02

Please sign in to comment.