Skip to content

Commit 17dc5b1

Browse files
committed
Tasty: Fix unpickling position of SHARED nodes
1 parent a6394e9 commit 17dc5b1

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1090,7 +1090,19 @@ class TreeUnpickler(reader: TastyReader,
10901090
if (ctx.mode.is(Mode.ReadPositions)) {
10911091
posUnpicklerOpt match {
10921092
case Some(posUnpickler) =>
1093-
posUnpickler.posAt(addr)
1093+
val addrPos = posUnpickler.posAt(addr)
1094+
if (addrPos == NoPosition && bytes(index(addr)) == SHARED) {
1095+
// Note: A tree can only be represented by a SHARED node if it's
1096+
// identical to some other tree, so you might wonder why we even
1097+
// bother checking addrPos for such nodes. It's because TypeTrees
1098+
// can be pickled as just a type and still have their own position,
1099+
// even if the type is just a SHARED node.
1100+
1101+
val sharedFork = forkAt(addr)
1102+
sharedFork.reader.readByte()
1103+
posAt(sharedFork.reader.readAddr())
1104+
}
1105+
else addrPos
10941106
case _ =>
10951107
NoPosition
10961108
}

0 commit comments

Comments
 (0)