diff --git a/compiler/src/dotty/tools/dotc/ast/DesugarEnums.scala b/compiler/src/dotty/tools/dotc/ast/DesugarEnums.scala index 98873dba85c7..2985a918c6ee 100644 --- a/compiler/src/dotty/tools/dotc/ast/DesugarEnums.scala +++ b/compiler/src/dotty/tools/dotc/ast/DesugarEnums.scala @@ -126,7 +126,7 @@ object DesugarEnums { val valuesOfBody: Tree = val defaultCase = - val msg = Apply(Select(Literal(Constant(s"enum ${enumClass.fullName} has no case with name: ")), nme.PLUS), Ident(nme.nameDollar)) + val msg = Apply(Select(Literal(Constant(i"enum $rawEnumClassRef has no case with name: ")), nme.PLUS), Ident(nme.nameDollar)) CaseDef(Ident(nme.WILDCARD), EmptyTree, Throw(New(TypeTree(defn.IllegalArgumentExceptionType), List(msg :: Nil)))) val stringCases = enumValues.map(enumValue => @@ -143,12 +143,13 @@ object DesugarEnums { } private def enumLookupMethods(constraints: EnumConstraints)(using Context): List[Tree] = + val rawEnumClassRef = rawRef(enumClass.typeRef) def scaffolding: List[Tree] = if constraints.isEnumeration then enumScaffolding(constraints.enumCases.map(_._2)) else Nil def valueCtor: List[Tree] = if constraints.requiresCreator then enumValueCreator :: Nil else Nil def fromOrdinal: Tree = def throwArg(ordinal: Tree) = - val msg = Apply(Select(Literal(Constant(s"enum ${enumClass.fullName} has no case with ordinal: ")), nme.PLUS), Select(ordinal, nme.toString_)) + val msg = Apply(Select(Literal(Constant(i"enum $rawEnumClassRef has no case with ordinal: ")), nme.PLUS), Select(ordinal, nme.toString_)) Throw(New(TypeTree(defn.NoSuchElementExceptionType), List(msg :: Nil))) if !constraints.cached then fromOrdinalMeth(throwArg)