diff options
author | Guillaume Martres <smarter@ubuntu.com> | 2016-11-21 20:00:24 +0100 |
---|---|---|
committer | Guillaume Martres <smarter@ubuntu.com> | 2016-11-22 01:35:08 +0100 |
commit | 9222af0bb61921f20417112c9d4a4ccce5b0d01a (patch) | |
tree | 60ff1d83435fb9eb2b066e5e2fc9bb88486aef74 /compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala | |
parent | e50afe94eec1824fb4e9dd9ddbbbfbc53c8d72eb (diff) | |
download | dotty-9222af0bb61921f20417112c9d4a4ccce5b0d01a.tar.gz dotty-9222af0bb61921f20417112c9d4a4ccce5b0d01a.tar.bz2 dotty-9222af0bb61921f20417112c9d4a4ccce5b0d01a.zip |
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.
Diffstat (limited to 'compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala')
-rw-r--r-- | compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala b/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala index 925e39ce9..66cfcf453 100644 --- a/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala +++ b/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala @@ -1026,7 +1026,10 @@ class TreeUnpickler(reader: TastyReader, tastyName: TastyName.Table, posUnpickle case APPLIEDtpt => AppliedTypeTree(readTpt(), until(end)(readTpt())) case ANDtpt => - AndTypeTree(readTpt(), readTpt()) + val tpt1 = readTpt() + val tpt2 = readTpt() + // FIXME: We need to do this instead of "AndType(tpt1, tpt2)" to avoid self-type cyclic reference in tasty_tools + untpd.AndTypeTree(tpt1, tpt2).withType(AndType(tpt1.tpe, tpt2.tpe)) case ORtpt => OrTypeTree(readTpt(), readTpt()) case ANNOTATEDtpt => @@ -1046,7 +1049,8 @@ class TreeUnpickler(reader: TastyReader, tastyName: TastyName.Table, posUnpickle } val tree = if (tag < firstLengthTreeTag) readSimpleTerm() else readLengthTerm() - tree.overwriteType(tree.tpe.simplified) + if (!tree.isInstanceOf[TypTree]) // FIXME: Necessary to avoid self-type cyclic reference in tasty_tools + tree.overwriteType(tree.tpe.simplified) setPos(start, tree) } |