@@ -36,7 +36,7 @@ class TupleOptimizations extends MiniPhase with IdentityDenotTransformer {
3636
3737 private def transformTupleCons (tree : tpd.Apply )(implicit ctx : Context ): Tree = {
3838 val head :: tail :: Nil = tree.args
39- tupleTypes(tree.tpe) match {
39+ defn. tupleTypes(tree.tpe) match {
4040 case Some (tpes) =>
4141 // Generate a the tuple directly with TupleN+1.apply
4242 val size = tpes.size
@@ -64,7 +64,7 @@ class TupleOptimizations extends MiniPhase with IdentityDenotTransformer {
6464
6565 private def transformTupleTail (tree : tpd.Apply )(implicit ctx : Context ): Tree = {
6666 val Apply (TypeApply (_, tpt :: Nil ), tup :: Nil ) = tree
67- tupleTypes(tpt.tpe, MaxTupleArity + 1 ) match {
67+ defn. tupleTypes(tpt.tpe, MaxTupleArity + 1 ) match {
6868 case Some (tpes) =>
6969 // Generate a the tuple directly with TupleN-1.apply
7070 val size = tpes.size
@@ -111,7 +111,7 @@ class TupleOptimizations extends MiniPhase with IdentityDenotTransformer {
111111 private def transformTupleConcat (tree : tpd.Apply )(implicit ctx : Context ): Tree = {
112112 val Apply (TypeApply (_, selfTp :: thatTp :: Nil ), self :: that :: Nil ) = tree
113113
114- (tupleTypes(selfTp.tpe), tupleTypes(that.tpe.widenTermRefExpr)) match {
114+ (defn. tupleTypes(selfTp.tpe), defn. tupleTypes(that.tpe.widenTermRefExpr)) match {
115115 case (Some (tpes1), Some (tpes2)) =>
116116 // Generate a the tuple directly with TupleN+M.apply
117117 val n = tpes1.size
@@ -146,7 +146,7 @@ class TupleOptimizations extends MiniPhase with IdentityDenotTransformer {
146146
147147 private def transformTupleApply (tree : tpd.Apply )(implicit ctx : Context ): Tree = {
148148 val Apply (TypeApply (_, tpt :: nTpt :: Nil ), tup :: nTree :: Nil ) = tree
149- (tupleTypes(tpt.tpe), nTpt.tpe) match {
149+ (defn. tupleTypes(tpt.tpe), nTpt.tpe) match {
150150 case (Some (tpes), nTpe : ConstantType ) =>
151151 // Get the element directly with TupleM._n+1 or TupleXXL.productElement(n)
152152 val size = tpes.size
@@ -173,7 +173,7 @@ class TupleOptimizations extends MiniPhase with IdentityDenotTransformer {
173173
174174 private def transformTupleToArray (tree : tpd.Apply )(implicit ctx : Context ): Tree = {
175175 val Apply (_, tup :: Nil ) = tree
176- tupleTypes(tup.tpe.widen, MaxTupleArity ) match {
176+ defn. tupleTypes(tup.tpe.widen, MaxTupleArity ) match {
177177 case Some (tpes) =>
178178 val size = tpes.size
179179 if (size == 0 ) {
@@ -222,17 +222,6 @@ class TupleOptimizations extends MiniPhase with IdentityDenotTransformer {
222222 }
223223 }
224224
225- private def tupleTypes (tp : Type , bound : Int = Int .MaxValue )(implicit ctx : Context ): Option [List [Type ]] = {
226- @ tailrec def rec (tp : Type , acc : List [Type ], bound : Int ): Option [List [Type ]] = tp match {
227- case _ if bound < 0 => Some (acc.reverse)
228- case tp : AppliedType if defn.PairClass == tp.classSymbol => rec(tp.args(1 ), tp.args.head :: acc, bound - 1 )
229- case tp : AppliedType if defn.isTupleClass(tp.tycon.classSymbol) => Some (acc.reverse ::: tp.args)
230- case tp if tp.classSymbol == defn.UnitClass => Some (acc.reverse)
231- case _ => None
232- }
233- rec(tp.stripTypeVar, Nil , bound)
234- }
235-
236225 private def tupleSelectors (tup : Tree , size : Int )(implicit ctx : Context ): List [Tree ] =
237226 (0 until size).map(i => tup.select(nme.selectorName(i))).toList
238227
0 commit comments