Skip to content

Commit 4bcadd2

Browse files
committed
Fixes #6626. Refrain from calling asSimpleName method on DerivedName
1 parent 8535975 commit 4bcadd2

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

compiler/src/dotty/tools/dotc/transform/GenericSignatures.scala

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import core.Annotations.Annotation
66
import core.Contexts.Context
77
import core.Definitions
88
import core.Flags._
9-
import core.Names.Name
9+
import core.Names.{DerivedName, Name, SimpleName, TypeName}
1010
import core.Symbols._
1111
import core.TypeApplications.TypeParamInfo
1212
import core.TypeErasure.erasure
@@ -17,6 +17,8 @@ import SymUtils._
1717
import TypeUtils._
1818
import java.lang.StringBuilder
1919

20+
import scala.annotation.tailrec
21+
2022
/** Helper object to generate generic java signatures, as defined in
2123
* the Java Virtual Machine Specification, §4.3.4
2224
*/
@@ -161,7 +163,14 @@ object GenericSignatures {
161163

162164
// TODO revisit this. Does it align with javac for code that can be expressed in both languages?
163165
val delimiter = if (builder.charAt(builder.length() - 1) == '>') '.' else '$'
164-
builder.append(delimiter).append(sanitizeName(sym.name.asSimpleName))
166+
167+
@tailrec def appendIfNotDerivedName(name: Name): Unit = name match {
168+
case _: DerivedName => //do nothing
169+
case typeName: TypeName => appendIfNotDerivedName(typeName.toTermName)
170+
case _ => builder.append(delimiter).append(sanitizeName(name.asSimpleName))
171+
}
172+
173+
appendIfNotDerivedName(sym.name)
165174
}
166175
else fullNameInSig(sym)
167176
}

0 commit comments

Comments
 (0)