Skip to content

Commit e7c96cb

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 e7c96cb

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-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 =>

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)