@@ -36,7 +36,7 @@ class TupleOptimizations extends MiniPhase with IdentityDenotTransformer {
36
36
37
37
private def transformTupleCons (tree : tpd.Apply )(implicit ctx : Context ): Tree = {
38
38
val head :: tail :: Nil = tree.args
39
- tupleTypes(tree.tpe) match {
39
+ defn. tupleTypes(tree.tpe) match {
40
40
case Some (tpes) =>
41
41
// Generate a the tuple directly with TupleN+1.apply
42
42
val size = tpes.size
@@ -64,7 +64,7 @@ class TupleOptimizations extends MiniPhase with IdentityDenotTransformer {
64
64
65
65
private def transformTupleTail (tree : tpd.Apply )(implicit ctx : Context ): Tree = {
66
66
val Apply (TypeApply (_, tpt :: Nil ), tup :: Nil ) = tree
67
- tupleTypes(tpt.tpe, MaxTupleArity + 1 ) match {
67
+ defn. tupleTypes(tpt.tpe, MaxTupleArity + 1 ) match {
68
68
case Some (tpes) =>
69
69
// Generate a the tuple directly with TupleN-1.apply
70
70
val size = tpes.size
@@ -111,7 +111,7 @@ class TupleOptimizations extends MiniPhase with IdentityDenotTransformer {
111
111
private def transformTupleConcat (tree : tpd.Apply )(implicit ctx : Context ): Tree = {
112
112
val Apply (TypeApply (_, selfTp :: thatTp :: Nil ), self :: that :: Nil ) = tree
113
113
114
- (tupleTypes(selfTp.tpe), tupleTypes(that.tpe.widenTermRefExpr)) match {
114
+ (defn. tupleTypes(selfTp.tpe), defn. tupleTypes(that.tpe.widenTermRefExpr)) match {
115
115
case (Some (tpes1), Some (tpes2)) =>
116
116
// Generate a the tuple directly with TupleN+M.apply
117
117
val n = tpes1.size
@@ -146,7 +146,7 @@ class TupleOptimizations extends MiniPhase with IdentityDenotTransformer {
146
146
147
147
private def transformTupleApply (tree : tpd.Apply )(implicit ctx : Context ): Tree = {
148
148
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 {
150
150
case (Some (tpes), nTpe : ConstantType ) =>
151
151
// Get the element directly with TupleM._n+1 or TupleXXL.productElement(n)
152
152
val size = tpes.size
@@ -173,7 +173,7 @@ class TupleOptimizations extends MiniPhase with IdentityDenotTransformer {
173
173
174
174
private def transformTupleToArray (tree : tpd.Apply )(implicit ctx : Context ): Tree = {
175
175
val Apply (_, tup :: Nil ) = tree
176
- tupleTypes(tup.tpe.widen, MaxTupleArity ) match {
176
+ defn. tupleTypes(tup.tpe.widen, MaxTupleArity ) match {
177
177
case Some (tpes) =>
178
178
val size = tpes.size
179
179
if (size == 0 ) {
@@ -222,17 +222,6 @@ class TupleOptimizations extends MiniPhase with IdentityDenotTransformer {
222
222
}
223
223
}
224
224
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
-
236
225
private def tupleSelectors (tup : Tree , size : Int )(implicit ctx : Context ): List [Tree ] =
237
226
(0 until size).map(i => tup.select(nme.selectorName(i))).toList
238
227
0 commit comments