Skip to content

Commit ade4910

Browse files
Expose tpd problem, temporary .toString hack
The situation is a follows: Without this commit `testOnly dotty.tools.dotc.CompilationTests -- *testPickling` fail with more precise types after pickling. Reverting tpd.scala to master breaks the "tree referencial equiality" condition used in Simplify to detect a fix point. For example `vulpix t7336.scala` (this one also requires the Skolem#toString change). This hack is sufficent for Simplify to reach its fix points without breaking pickling... [SQUASH] [TODO] fix tpd .toString hack
1 parent ce75a8c commit ade4910

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

compiler/src/dotty/tools/dotc/ast/tpd.scala

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -473,23 +473,30 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
473473
}
474474

475475
override def Apply(tree: Tree)(fun: Tree, args: List[Tree])(implicit ctx: Context): Apply = {
476+
// @Dmitry: current implementation in master:
477+
// ta.assignType(untpd.cpy.Apply(tree)(fun, args), fun, args)
476478
val untyped = untpd.cpy.Apply(tree)(fun, args)
477-
if (untyped ne tree)
478-
ta.assignType(untyped, fun, args)
479-
else tree.asInstanceOf[Apply]
479+
val typed = ta.assignType(untyped, fun, args)
480+
if (untyped.ne(tree) || tree.tpe.toString != typed.tpe.toString)
481+
typed
482+
else
483+
tree.asInstanceOf[Apply]
480484
}
481485
// Note: Reassigning the original type if `fun` and `args` have the same types as before
482486
// does not work here: The computed type depends on the widened function type, not
483487
// the function type itself. A treetransform may keep the function type the
484488
// same but its widened type might change.
485489

486490
override def TypeApply(tree: Tree)(fun: Tree, args: List[Tree])(implicit ctx: Context): TypeApply = {
491+
// @Dmitry: current implementation in master:
492+
// ta.assignType(untpd.cpy.TypeApply(tree)(fun, args), fun, args)
487493
val untyped = untpd.cpy.TypeApply(tree)(fun, args)
488-
if (untyped ne tree)
489-
ta.assignType(untyped, fun, args)
490-
else tree.asInstanceOf[TypeApply]
494+
val typed = ta.assignType(untyped, fun, args)
495+
if (untyped.ne(tree) || tree.tpe.toString != typed.tpe.toString)
496+
typed
497+
else
498+
tree.asInstanceOf[TypeApply]
491499
}
492-
// FIXME
493500
// Same remark as for Apply
494501

495502
override def Literal(tree: Tree)(const: Constant)(implicit ctx: Context): Literal =
@@ -524,11 +531,14 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
524531
}
525532

526533
override def Closure(tree: Tree)(env: List[Tree], meth: Tree, tpt: Tree)(implicit ctx: Context): Closure = {
534+
// @Dmitry: current implementation in master:
535+
// ta.assignType(untpd.cpy.Closure(tree)(env, meth, tpt), meth, tpt)
527536
val untyped = untpd.cpy.Closure(tree)(env, meth, tpt)
528-
if (untyped ne tree)
529-
ta.assignType(untyped, meth, tpt)
530-
else tree.asInstanceOf[Closure]
531-
537+
val typed = ta.assignType(untyped, meth, tpt)
538+
if (untyped.ne(tree) || tree.tpe.toString != typed.tpe.toString)
539+
typed
540+
else
541+
tree.asInstanceOf[Closure]
532542
}
533543
// Same remark as for Apply
534544

0 commit comments

Comments
 (0)