Skip to content

Commit dfd5ace

Browse files
committed
Fix #5015: disallow empty enum definition
1 parent b26740d commit dfd5ace

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2556,6 +2556,11 @@ object Parsers {
25562556
val clsName = modName.toTypeName
25572557
val constr = classConstr()
25582558
val templ = templateOpt(constr, isEnum = true)
2559+
templ match {
2560+
case Template(_, _, _, List(EmptyTree)) =>
2561+
syntaxError("enum body should not be empty.", start)
2562+
case _ =>
2563+
}
25592564
finalizeDef(TypeDef(clsName, templ), addMod(mods, enumMod), start)
25602565
}
25612566

tests/neg/i5015.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
enum A extends AnyRef { } // error

0 commit comments

Comments
 (0)