Skip to content

Commit 564a764

Browse files
Kinda fix toString hack: testPicking w/o -optimise + tpd swtich
1 parent 682cd81 commit 564a764

File tree

2 files changed

+33
-26
lines changed

2 files changed

+33
-26
lines changed

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

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -473,29 +473,33 @@ 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)
478-
val untyped = untpd.cpy.Apply(tree)(fun, args)
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]
476+
if (ctx.settings.optimise.value) {
477+
val untyped = untpd.cpy.Apply(tree)(fun, args)
478+
val typed = ta.assignType(untyped, fun, args)
479+
if (untyped.ne(tree))
480+
typed
481+
else
482+
tree.asInstanceOf[Apply]
483+
} else {
484+
ta.assignType(untpd.cpy.Apply(tree)(fun, args), fun, args)
485+
}
484486
}
485487
// Note: Reassigning the original type if `fun` and `args` have the same types as before
486488
// does not work here: The computed type depends on the widened function type, not
487489
// the function type itself. A treetransform may keep the function type the
488490
// same but its widened type might change.
489491

490492
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)
493-
val untyped = untpd.cpy.TypeApply(tree)(fun, args)
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]
493+
if (ctx.settings.optimise.value) {
494+
val untyped = untpd.cpy.TypeApply(tree)(fun, args)
495+
val typed = ta.assignType(untyped, fun, args)
496+
if (untyped.ne(tree))
497+
typed
498+
else
499+
tree.asInstanceOf[TypeApply]
500+
} else {
501+
ta.assignType(untpd.cpy.TypeApply(tree)(fun, args), fun, args)
502+
}
499503
}
500504
// Same remark as for Apply
501505

@@ -531,14 +535,16 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
531535
}
532536

533537
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)
536-
val untyped = untpd.cpy.Closure(tree)(env, meth, tpt)
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]
538+
if (ctx.settings.optimise.value) {
539+
val untyped = untpd.cpy.Closure(tree)(env, meth, tpt)
540+
val typed = ta.assignType(untyped, meth, tpt)
541+
if (untyped.ne(tree))
542+
typed
543+
else
544+
tree.asInstanceOf[Closure]
545+
} else {
546+
ta.assignType(untpd.cpy.Closure(tree)(env, meth, tpt), meth, tpt)
547+
}
542548
}
543549
// Same remark as for Apply
544550

compiler/test/dotty/tools/vulpix/TestConfiguration.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,11 @@ object TestConfiguration {
5252

5353
private val yCheckOptions = Array("-Ycheck:tailrec,resolveSuper,mixin,arrayConstructors,labelDef")
5454

55-
val defaultOptions = noCheckOptions ++ checkOptions ++ yCheckOptions ++ classPath :+ "-optimise"
55+
val defaultUnoptimised = noCheckOptions ++ checkOptions ++ yCheckOptions ++ classPath
56+
val defaultOptions = defaultUnoptimised :+ "-optimise"
5657
val allowDeepSubtypes = defaultOptions diff Array("-Yno-deep-subtypes")
5758
val allowDoubleBindings = defaultOptions diff Array("-Yno-double-bindings")
58-
val picklingOptions = defaultOptions ++ Array(
59+
val picklingOptions = defaultUnoptimised ++ Array(
5960
"-Xprint-types",
6061
"-Ytest-pickler",
6162
"-Yprintpos"

0 commit comments

Comments
 (0)