@@ -34,6 +34,9 @@ class Simplify extends MiniPhaseTransform with IdentityDenotTransformer {
3434 private var symmetricOperations : Set [Symbol ] = null
3535 var optimize = false
3636
37+
38+ override val cpy = tpd.cpy
39+
3740 override def prepareForUnit (tree : Tree )(implicit ctx : Context ): TreeTransform = {
3841 SeqFactoryClass = ctx.requiredClass(" scala.collection.generic.SeqFactory" )
3942 symmetricOperations = Set (defn.Boolean_&& , defn.Boolean_|| , defn.Int_+ , defn.Int_* , defn.Long_+ , defn.Long_* )
@@ -118,7 +121,7 @@ class Simplify extends MiniPhaseTransform with IdentityDenotTransformer {
118121 transformers = transformers.tail
119122 }
120123 }
121- if (rhs0 ne tree.rhs) cpy.DefDef (tree)(rhs = rhs0)
124+ if (rhs0 ne tree.rhs) tpd. cpy.DefDef (tree)(rhs = rhs0)
122125 else tree
123126 } else tree
124127 }
@@ -539,8 +542,8 @@ class Simplify extends MiniPhaseTransform with IdentityDenotTransformer {
539542
540543 def splitWrites (t : Tree , target : Symbol ): Tree = {
541544 t match {
542- case tree@ Block (stats, expr) => cpy.Block (tree)(stats, splitWrites(expr, target))
543- case tree@ If (_, thenp, elsep) => cpy.If (tree)(thenp = splitWrites(thenp, target), elsep = splitWrites(elsep, target))
545+ case tree@ Block (stats, expr) => tpd. cpy.Block (tree)(stats, splitWrites(expr, target))
546+ case tree@ If (_, thenp, elsep) => tpd. cpy.If (tree)(thenp = splitWrites(thenp, target), elsep = splitWrites(elsep, target))
544547 case Apply (sel , args) if sel.symbol.isConstructor && t.tpe.widenDealias == target.info.widenDealias.finalResultType.widenDealias =>
545548 val fieldsByAccessors = newMappings(target)
546549 var accessors = target.info.classSymbol.caseAccessors.filter(_.isGetter) // TODO: when is this filter needed?
@@ -588,7 +591,7 @@ class Simplify extends MiniPhaseTransform with IdentityDenotTransformer {
588591 case ddef : DefDef if ddef.symbol.is(Label ) =>
589592 newMappings.get(followCases(ddef.symbol)) match {
590593 case Some (mappings) =>
591- cpy.DefDef (ddef)(rhs = splitWrites(ddef.rhs, followCases(ddef.symbol)))
594+ tpd. cpy.DefDef (ddef)(rhs = splitWrites(ddef.rhs, followCases(ddef.symbol)))
592595 case _ => ddef
593596 }
594597 case a : ValDef if toSplit.contains(a.symbol) =>
@@ -597,7 +600,7 @@ class Simplify extends MiniPhaseTransform with IdentityDenotTransformer {
597600 val newFields = newMappings(a.symbol).values.toSet
598601 Thicket (
599602 newFields.map(x => ValDef (x.asTerm, defaultValue(x.symbol.info.widenDealias))).toList :::
600- List (cpy.ValDef (a)(rhs = splitWrites(a.rhs, a.symbol))))
603+ List (tpd. cpy.ValDef (a)(rhs = splitWrites(a.rhs, a.symbol))))
601604 case ass : Assign =>
602605 newMappings.get(ass.lhs.symbol) match {
603606 case None => ass
@@ -685,7 +688,7 @@ class Simplify extends MiniPhaseTransform with IdentityDenotTransformer {
685688 }
686689 val nthenp = dropGoodCastsInStats.transform(thenp)
687690
688- cpy.If (t)(thenp = nthenp, elsep = elsep)
691+ tpd. cpy.If (t)(thenp = nthenp, elsep = elsep)
689692 case t => t
690693 }
691694 (" dropGoodCasts" , BeforeAndAfterErasure , NoVisitor , transformer)
@@ -824,7 +827,7 @@ class Simplify extends MiniPhaseTransform with IdentityDenotTransformer {
824827 val nthenp = keepOnlySideEffects(thenp)
825828 val nelsep = keepOnlySideEffects(elsep)
826829 if (thenp.isEmpty && elsep.isEmpty) keepOnlySideEffects(cond)
827- else cpy.If (t)(
830+ else tpd. cpy.If (t)(
828831 thenp = nthenp.orElse(if (thenp.isInstanceOf [Literal ]) thenp else unitLiteral),
829832 elsep = nelsep.orElse(if (elsep.isInstanceOf [Literal ]) elsep else unitLiteral))
830833 case Select (rec, _) if
@@ -845,7 +848,7 @@ class Simplify extends MiniPhaseTransform with IdentityDenotTransformer {
845848 case t : Literal if t.tpe.derivesFrom(defn.UnitClass ) => expr
846849 case _ => keepOnlySideEffects(expr).orElse(unitLiteral)
847850 }
848- cpy.Block (bl)(stats2, expr2)
851+ tpd. cpy.Block (bl)(stats2, expr2)
849852 case t : Ident if ! t.symbol.is(Method | Lazy ) && ! t.symbol.info.isInstanceOf [ExprType ] =>
850853 desugarIdent(t) match {
851854 case Some (t) => t
@@ -914,7 +917,7 @@ class Simplify extends MiniPhaseTransform with IdentityDenotTransformer {
914917 case _ => (newStats1, a.expr)
915918 }
916919 if (newStats2.nonEmpty)
917- cpy.Block (a)(stats = newStats2, newExpr)
920+ tpd. cpy.Block (a)(stats = newStats2, newExpr)
918921 else newExpr
919922 case a : DefDef =>
920923 if (a.symbol.info.finalResultType.derivesFrom(defn.UnitClass ) &&
@@ -924,7 +927,7 @@ class Simplify extends MiniPhaseTransform with IdentityDenotTransformer {
924927 if (! t.tpe.derivesFrom(defn.UnitClass )) Block (t :: Nil , unitLiteral)
925928 else t
926929 }
927- cpy.DefDef (a)(rhs = insertUnit(keepOnlySideEffects(a.rhs)), tpt = TypeTree (defn.UnitType ))
930+ tpd. cpy.DefDef (a)(rhs = insertUnit(keepOnlySideEffects(a.rhs)), tpt = TypeTree (defn.UnitType ))
928931 } else a
929932 case t => t
930933 }
@@ -1120,7 +1123,7 @@ class Simplify extends MiniPhaseTransform with IdentityDenotTransformer {
11201123 }
11211124
11221125 if (newStats eq t.stats) t
1123- else cpy.Block (t)(newStats, t.expr)
1126+ else tpd. cpy.Block (t)(newStats, t.expr)
11241127 case tree => tree
11251128 }
11261129
0 commit comments