@@ -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
0 commit comments