From 0ecbcfb483cfce01b09ef2295878ff6ee1e92dfe Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Mon, 18 Dec 2023 13:04:41 +0100 Subject: [PATCH] Do not access enum symbol in `DesugarEnums` Follow up of #19182. Using `fullName` causes the the `parallelBackend` tests to loop forever. Fixes #19285 Fixes #19281 Fixes #19278 --- compiler/src/dotty/tools/dotc/ast/DesugarEnums.scala | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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)