Skip to content

Commit 9222af0

Browse files
committed
TreeUnpickler: Workaround cyclic reference involving self-type
Special-casing like this is ugly, we should decide whether we want to avoid simplifications on all TypTrees and whether we want to do this just in unpickler or always. But I want to merge this PR first.
1 parent e50afe9 commit 9222af0

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,7 +1026,10 @@ class TreeUnpickler(reader: TastyReader, tastyName: TastyName.Table, posUnpickle
10261026
case APPLIEDtpt =>
10271027
AppliedTypeTree(readTpt(), until(end)(readTpt()))
10281028
case ANDtpt =>
1029-
AndTypeTree(readTpt(), readTpt())
1029+
val tpt1 = readTpt()
1030+
val tpt2 = readTpt()
1031+
// FIXME: We need to do this instead of "AndType(tpt1, tpt2)" to avoid self-type cyclic reference in tasty_tools
1032+
untpd.AndTypeTree(tpt1, tpt2).withType(AndType(tpt1.tpe, tpt2.tpe))
10301033
case ORtpt =>
10311034
OrTypeTree(readTpt(), readTpt())
10321035
case ANNOTATEDtpt =>
@@ -1046,7 +1049,8 @@ class TreeUnpickler(reader: TastyReader, tastyName: TastyName.Table, posUnpickle
10461049
}
10471050

10481051
val tree = if (tag < firstLengthTreeTag) readSimpleTerm() else readLengthTerm()
1049-
tree.overwriteType(tree.tpe.simplified)
1052+
if (!tree.isInstanceOf[TypTree]) // FIXME: Necessary to avoid self-type cyclic reference in tasty_tools
1053+
tree.overwriteType(tree.tpe.simplified)
10501054
setPos(start, tree)
10511055
}
10521056

0 commit comments

Comments
 (0)