Skip to content

Commit b8c4755

Browse files
Fix #6151: MatchError for imported java enum Values
When emitting annotations' arguments from the `DottyBackendInterface`, the case when the argument value can be an `Ident` is not considered. This commit adds such a case and implements it similarly to that of the `Select` one.
1 parent 574fd0c commit b8c4755

File tree

4 files changed

+10
-0
lines changed

4 files changed

+10
-0
lines changed

compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,11 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
306306
val desc = innerClasesStore.typeDescriptor(typ.asInstanceOf[bcodeStore.int.Type]) // the class descriptor of the nested annotation class
307307
val nestedVisitor = av.visitAnnotation(name, desc)
308308
emitAssocs(nestedVisitor, assocs, bcodeStore)(innerClasesStore)
309+
310+
case t: tpd.Ident if t.symbol.denot.owner.is(Flags.JavaEnum) =>
311+
val edesc = innerClasesStore.typeDescriptor(t.tpe.asInstanceOf[bcodeStore.int.Type]) // the class descriptor of the enumeration class.
312+
val evalue = t.symbol.name.mangledString // value the actual enumeration value.
313+
av.visitEnum(name, edesc, evalue)
309314
}
310315
}
311316

tests/pos/i6151/Expect.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
public enum Expect { ExpectVal }

tests/pos/i6151/Outcome.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
public @interface Outcome { Expect enm(); }

tests/pos/i6151/Test.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import Expect._
2+
@Outcome(ExpectVal)
3+
class SimpleTest

0 commit comments

Comments
 (0)