Skip to content

Commit 934f173

Browse files
committed
Upgrade sealed object to error
1 parent cc822fb commit 934f173

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

compiler/src/dotty/tools/dotc/parsing/Parsers.scala

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2319,11 +2319,12 @@ object Parsers {
23192319

23202320
def flagPos(flag: FlagSet) = mods.mods.find(_.flags == flag).get.pos
23212321
if (mods is Abstract)
2322-
syntaxError(hl"""${"abstract"} modifier cannot be used for objects""", flagPos(Abstract))
2323-
for (flag <- List(Sealed, Final)) {
2324-
if (mods is flag)
2325-
warning(hl"""$flag modifier is redundant for objects""", source atPos flagPos(flag))
2326-
}
2322+
syntaxError(hl"""${Abstract} modifier cannot be used for objects""", flagPos(Abstract))
2323+
if (mods is Sealed)
2324+
syntaxError(hl"""${Sealed} modifier is redundant for objects""", flagPos(Sealed))
2325+
// XXX Make this an error.
2326+
if (mods is Final)
2327+
warning(hl"""${Final} modifier is redundant for objects""", source atPos flagPos(Final))
23272328

23282329
ModuleDef(name, template).withMods(mods).setComment(in.getDocComment(start))
23292330
}

0 commit comments

Comments
 (0)