Skip to content

Commit fd6f62a

Browse files
authored
Merge pull request #5514 from dotty-staging/fix-unpickling-rectype
Fix #5488: properly unpickle RecTypes
2 parents 1c03333 + 493c2e9 commit fd6f62a

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
@@ -393,7 +393,13 @@ class TreeUnpickler(reader: TastyReader,
393393
case THIS =>
394394
ThisType.raw(readType().asInstanceOf[TypeRef])
395395
case RECtype =>
396-
typeAtAddr.getOrElse(start, RecType(rt => registeringType(rt, readType())))
396+
typeAtAddr.get(start) match {
397+
case Some(tp) =>
398+
skipTree(tag)
399+
tp
400+
case None =>
401+
RecType(rt => registeringType(rt, readType()))
402+
}
397403
case RECthis =>
398404
readTypeRef().asInstanceOf[RecType].recThis
399405
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)