Skip to content

Commit 493c2e9

Browse files
committed
Fix #5488: properly unpickle RecTypes
If the type is already present in typeAtAddr, then we don't unpickle it again, but we forgot to skip over it before moving on.
1 parent d56af69 commit 493c2e9

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,13 @@ class TreeUnpickler(reader: TastyReader,
392392
case THIS =>
393393
ThisType.raw(readType().asInstanceOf[TypeRef])
394394
case RECtype =>
395-
typeAtAddr.getOrElse(start, RecType(rt => registeringType(rt, readType())))
395+
typeAtAddr.get(start) match {
396+
case Some(tp) =>
397+
skipTree(tag)
398+
tp
399+
case None =>
400+
RecType(rt => registeringType(rt, readType()))
401+
}
396402
case RECthis =>
397403
readTypeRef().asInstanceOf[RecType].recThis
398404
case TYPEALIAS =>

compiler/test/dotc/pos-decompilation.blacklist

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@ tcpoly_checkkinds_mix.scala
1212
i3050.scala
1313
i4006b.scala
1414
i4006c.scala
15+
16+
# Decompiling RecThis as "this" is incorrect
17+
avoid.scala

tests/pos/avoid.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ object test {
99
val z: String = x.y
1010
}
1111

12+
trait M
13+
1214
// A tricky case involving inner classes, exercised
1315
// in the large in dotty.tools.dotc.core.NameKinds.scala.
1416
object Test2 {
@@ -24,4 +26,9 @@ object Test2 {
2426
class C extends NK { type T = I }
2527
new C
2628
}
29+
30+
val z = {
31+
class C extends NK { type T = I }
32+
new C with M
33+
}
2734
}

0 commit comments

Comments
 (0)