Skip to content

Commit 8de82fc

Browse files
committed
Make PositionPickler work for shared trees
1 parent 43a102f commit 8de82fc

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

compiler/src/dotty/tools/dotc/core/tasty/PositionPickler.scala

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,13 @@ class PositionPickler(pickler: TastyPickler, addrOfTree: untpd.Tree => Option[Ad
7070
case x: untpd.Tree =>
7171
var sourceFile = current
7272
val pos = if (x.isInstanceOf[untpd.MemberDef]) x.pos else x.pos.toSynthetic
73-
if (pos.exists && (
74-
pos != x.initialPos.toSynthetic ||
75-
x.source.file != current ||
76-
alwaysNeedsPos(x))) {
73+
val sourceChange = x.source.file != current
74+
if (pos.exists && (pos != x.initialPos.toSynthetic || sourceChange || alwaysNeedsPos(x))) {
7775
addrOfTree(x) match {
78-
case Some(addr) if !pickledIndices.contains(addr.index) =>
76+
case Some(addr) if !pickledIndices.contains(addr.index) || sourceChange =>
77+
// we currently do not share trees when unpickling, so if one path to a tree contains
78+
// a source change while another does not, we have to record the position of the tree twice
79+
// in order not to miss the source change. Test case is t3232a.scala.
7980
//println(i"pickling $x with $pos at $addr")
8081
pickleDeltas(addr.index, pos)
8182
if (x.source.file != current) {

0 commit comments

Comments
 (0)