Skip to content

Commit 78ef6bb

Browse files
oderskyDarkDimius
authored andcommitted
Harmonize treatment of simplified between typer and unpickler
We got some spurious differences in the types in TemplateParents because simplification was done in Typer but not in Unpickler. With the change we get perfect matches for all files in pickleOK also if we print their types.
1 parent 3d987df commit 78ef6bb

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

src/dotty/tools/dotc/core/pickling/TreeUnpickler.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -787,10 +787,10 @@ class TreeUnpickler(reader: TastyReader, tastyName: TastyName.Table) {
787787
assert(currentAddr == end, s"$start $currentAddr $end ${astTagToString(tag)}")
788788
result
789789
}
790-
791-
setPos(start,
792-
if (tag < firstLengthTreeTag) readSimpleTerm()
793-
else readLengthTerm())
790+
791+
val tree = if (tag < firstLengthTreeTag) readSimpleTerm() else readLengthTerm()
792+
tree.overwriteType(tree.tpe.simplified)
793+
setPos(start, tree)
794794
}
795795

796796
def readTpt()(implicit ctx: Context) = {

src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
475475
val expr1 = ascribeType(expr, pt)
476476
cpy.Block(block)(stats, expr1) withType expr1.tpe // no assignType here because avoid is redundant
477477
case _ =>
478-
Typed(tree, TypeTree(pt))
478+
Typed(tree, TypeTree(pt.simplified))
479479
}
480480
val leaks = escapingRefs(tree, localSyms)
481481
if (leaks.isEmpty) tree

test/dotc/tests.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class tests extends CompilerTest {
3232
val newDir = "./tests/new/"
3333
val dotcDir = "./src/dotty/"
3434

35-
@Test def pickle_pickleOK = compileDir(posDir + "pickleOK/", testPickling)
35+
@Test def pickle_pickleOK = compileDir(posDir + "pickleOK/", "-Xprint-types" :: testPickling)
3636
@Test def pickle_pickling = compileDir(dotcDir + "tools/dotc/core/pickling", testPickling)
3737

3838
@Test def pos_t2168_pat = compileFile(posDir, "t2168")

0 commit comments

Comments
 (0)