diff --git a/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala b/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala index e2481234537f..72bd2aadb292 100644 --- a/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala +++ b/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala @@ -392,7 +392,13 @@ class TreeUnpickler(reader: TastyReader, case THIS => ThisType.raw(readType().asInstanceOf[TypeRef]) case RECtype => - typeAtAddr.getOrElse(start, RecType(rt => registeringType(rt, readType()))) + typeAtAddr.get(start) match { + case Some(tp) => + skipTree(tag) + tp + case None => + RecType(rt => registeringType(rt, readType())) + } case RECthis => readTypeRef().asInstanceOf[RecType].recThis case TYPEALIAS => diff --git a/compiler/test/dotc/pos-decompilation.blacklist b/compiler/test/dotc/pos-decompilation.blacklist index 7167432f404b..d02a16891b34 100644 --- a/compiler/test/dotc/pos-decompilation.blacklist +++ b/compiler/test/dotc/pos-decompilation.blacklist @@ -12,3 +12,6 @@ tcpoly_checkkinds_mix.scala i3050.scala i4006b.scala i4006c.scala + +# Decompiling RecThis as "this" is incorrect +avoid.scala diff --git a/tests/pos/avoid.scala b/tests/pos/avoid.scala index a9b633b772e9..617353d2a7c2 100644 --- a/tests/pos/avoid.scala +++ b/tests/pos/avoid.scala @@ -9,6 +9,8 @@ object test { val z: String = x.y } +trait M + // A tricky case involving inner classes, exercised // in the large in dotty.tools.dotc.core.NameKinds.scala. object Test2 { @@ -24,4 +26,9 @@ object Test2 { class C extends NK { type T = I } new C } + + val z = { + class C extends NK { type T = I } + new C with M + } }