Skip to content

Commit 09eddd0

Browse files
committed
Make sure local data is unpickled at right phase
We had a problem where unpickling an annotation containing a class constant had the wrong type. Unpickling was done after erasure. The type given to the constant was an alias but aliases got eliminated during erasure, so the constant was malformed. Unpickling annotation contents at the same phase as unpickling the annotation carrier solves the problem. It seems similar problems can arise when data is unpickled using a LocalUnpickler. So we now make sure local unpickling runs at the latest at phase Pickler.
1 parent 2443760 commit 09eddd0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,8 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
573573
// println(s"unpickled ${denot.debugString}, info = ${denot.info}") !!! DEBUG
574574
}
575575
atReadPos(startCoord(denot).toIndex,
576-
() => parseToCompletion(denot)(ctx.addMode(Mode.Scala2Unpickling)))
576+
() => parseToCompletion(denot)(
577+
ctx.addMode(Mode.Scala2Unpickling).withPhaseNoLater(ctx.picklerPhase)))
577578
} catch {
578579
case ex: RuntimeException => handleRuntimeException(ex)
579580
}
@@ -922,7 +923,8 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
922923
val start = readIndex
923924
val atp = readTypeRef()
924925
Annotation.deferred(
925-
atp.typeSymbol, implicit ctx => atReadPos(start, () => readAnnotationContents(end)))
926+
atp.typeSymbol, implicit ctx1 =>
927+
atReadPos(start, () => readAnnotationContents(end)(ctx1.withPhase(ctx.phase))))
926928
}
927929

928930
/* Read an abstract syntax tree */

0 commit comments

Comments
 (0)