@@ -478,7 +478,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
478478 val tree1 = untpd.cpy.Apply (tree)(fun, args)
479479 tree match {
480480 case tree : Apply
481- if (fun.tpe eq tree.fun.tpe) && (args corresponds tree.args)(_ eq _ ) =>
481+ if (fun.tpe eq tree.fun.tpe) && sameTypes (args, tree.args) =>
482482 tree1.withTypeUnchecked(tree.tpe)
483483 case _ => ta.assignType(tree1, fun, args)
484484 }
@@ -488,7 +488,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
488488 val tree1 = untpd.cpy.TypeApply (tree)(fun, args)
489489 tree match {
490490 case tree : TypeApply
491- if (fun.tpe eq tree.fun.tpe) && (args corresponds tree.args)(_ eq _ ) =>
491+ if (fun.tpe eq tree.fun.tpe) && sameTypes (args, tree.args) =>
492492 tree1.withTypeUnchecked(tree.tpe)
493493 case _ => ta.assignType(tree1, fun, args)
494494 }
@@ -525,10 +525,15 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
525525 }
526526 }
527527
528- override def Closure (tree : Tree )(env : List [Tree ], meth : Tree , tpt : Tree )(implicit ctx : Context ): Closure =
529- ta.assignType(untpd.cpy.Closure (tree)(env, meth, tpt), meth, tpt)
530- // Same remark as for Apply
531528
529+ override def Closure (tree : Tree )(env : List [Tree ], meth : Tree , tpt : Tree )(implicit ctx : Context ): Closure = {
530+ val tree1 = untpd.cpy.Closure (tree)(env, meth, tpt)
531+ tree match {
532+ case tree : Closure if sameTypes(env, tree.env) && (meth.tpe eq tree.meth.tpe) && (tpt.tpe eq tree.tpt.tpe) =>
533+ tree1.withTypeUnchecked(tree.tpe)
534+ case _ => ta.assignType(tree1, meth, tpt)
535+ }
536+ }
532537 override def Match (tree : Tree )(selector : Tree , cases : List [CaseDef ])(implicit ctx : Context ): Match = {
533538 val tree1 = untpd.cpy.Match (tree)(selector, cases)
534539 tree match {
@@ -596,6 +601,12 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
596601 override def TypeApply (tree : Tree )(fun : Tree , args : List [Tree ])(implicit ctx : Context ): TypeApply =
597602 ta.assignType(untpd.cpy.TypeApply (tree)(fun, args), fun, args)
598603 // Same remark as for Apply
604+
605+ override def Closure (tree : Tree )(env : List [Tree ], meth : Tree , tpt : Tree )(implicit ctx : Context ): Closure =
606+ ta.assignType(untpd.cpy.Closure (tree)(env, meth, tpt), meth, tpt)
607+
608+ override def Closure (tree : Closure )(env : List [Tree ] = tree.env, meth : Tree = tree.meth, tpt : Tree = tree.tpt)(implicit ctx : Context ): Closure =
609+ Closure (tree : Tree )(env, meth, tpt)
599610 }
600611
601612 override def skipTransform (tree : Tree )(implicit ctx : Context ) = tree.tpe.isError
0 commit comments