Skip to content

Commit 89d51d8

Browse files
author
Sebastian Nadorp
committed
Fix #4470: compiler crash for repeated Enums
1 parent 5d004dc commit 89d51d8

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

compiler/src/dotty/tools/dotc/ast/DesugarEnums.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,8 @@ object DesugarEnums {
210210

211211
/** Expand a simple enum case */
212212
def expandSimpleEnumCase(name: TermName, mods: Modifiers, pos: Position)(implicit ctx: Context): Tree =
213-
if (enumClass.typeParams.nonEmpty) {
213+
if(!enumClass.exists) EmptyTree
214+
else if (enumClass.typeParams.nonEmpty) {
214215
val parent = interpolatedEnumParent(pos)
215216
val impl = Template(emptyConstructor, parent :: Nil, EmptyValDef, Nil)
216217
expandEnumModule(name, impl, mods, pos)

tests/neg/enum-repeated-4470.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
object RepeatedEnum {
2+
3+
enum Maybe { //error
4+
case Foo
5+
}
6+
7+
enum Maybe { //error
8+
case Foo
9+
}
10+
}

0 commit comments

Comments
 (0)