Skip to content

Commit 48cec48

Browse files
committed
Fix scala#7991: don't set JavaDefined for Dotty Enum module class
Top-level Dotty Enum classes have the flag JAVA_ACC_ENUM. We cannot tell from the flag whether a class is JavaDefined or not. The `moduleRoot` already has the flag `JavaDefined` set, it suffices to test the flag.
1 parent 9322e8c commit 48cec48

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,12 +200,13 @@ class ClassfileParser(
200200
sym.markAbsent()
201201
}
202202

203-
// eager load java enum definitions for exhaustivity check of pattern match
203+
// eager load enum definitions for exhaustivity check of pattern match
204204
if (isEnum) {
205205
instanceScope.toList.map(_.ensureCompleted())
206206
staticScope.toList.map(_.ensureCompleted())
207-
classRoot.setFlag(Flags.JavaEnumTrait)
208-
moduleRoot.setFlag(Flags.JavaEnumTrait)
207+
val flag = if moduleRoot.is(Flags.JavaDefined) then Flags.JavaEnumTrait else Flags.Enum
208+
classRoot.setFlag(flag)
209+
moduleRoot.setFlag(flag)
209210
}
210211

211212
result

0 commit comments

Comments
 (0)