Skip to content

Commit 41cbd36

Browse files
committed
Fix #3873: Properly unpickle shared TypeTrees
When a TypeTree is represented by a SHAREDterm, we need to follow the SHAREDterm and call `readTpt()` again. We cannot rely on `readTerm()` following the SHAREDterm for us because a TypeTree can be pickled as just a type.
1 parent bfb65c6 commit 41cbd36

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1055,7 +1055,11 @@ class TreeUnpickler(reader: TastyReader,
10551055
}
10561056

10571057
def readTpt()(implicit ctx: Context) =
1058-
if (nextByte == SHAREDterm || isTypeTreeTag(nextUnsharedTag)) readTerm()
1058+
if (nextByte == SHAREDterm) {
1059+
readByte()
1060+
forkAt(readAddr()).readTpt()
1061+
}
1062+
else if (isTypeTreeTag(nextUnsharedTag)) readTerm()
10591063
else {
10601064
val start = currentAddr
10611065
val tp = readType()

tests/pos/i3873.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
object Test {
2+
inline def sum2(ys: List[Int]): Unit = {
3+
ys.foldLeft(1)
4+
}
5+
val h1: ((List[Int]) => Unit) = sum2
6+
}

0 commit comments

Comments
 (0)