Skip to content

Commit f5e8f90

Browse files
committed
Unmangle external references unpickled from Scala 2
This is necessary in particular to properly unpickle annotations with default arguments, since default arguments have mangled names, this is necessary to unpickle various parts of the 2.13 stdlib.
1 parent 22c2093 commit f5e8f90

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,18 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
348348
def atEnd = readIndex == end
349349

350350
def readExtSymbol(): Symbol = {
351-
val name = readNameRef().decode
351+
val nameRef = readNameRef()
352+
var name = nameRef.decode
353+
354+
// If the symbol tag is EXTMODCLASSref, then we know that the method names
355+
// mangling do not make sense, but in general we don't know what kind of
356+
// symbol we're reading at this point, so we don't know which unmanglings
357+
// are safe to apply. Empirically, we at least need to unmangle default
358+
// getter names, since they're used to encode the default parameters of
359+
// annotations, but more might be needed.
360+
if (tag != EXTMODCLASSref)
361+
name = name.unmangle(Scala2MethodNameKinds)
362+
352363
val owner = if (atEnd) loadingMirror.RootClass else readSymbolRef()
353364

354365
def adjust(denot: Denotation) = {

0 commit comments

Comments
 (0)