@@ -15,7 +15,6 @@ import MegaPhase._
15
15
import Types ._
16
16
import dotty .tools .dotc .ast .tpd
17
17
18
-
19
18
import scala .annotation .tailrec
20
19
21
20
/** TODO
@@ -26,17 +25,20 @@ class GenericTuples extends MiniPhase with IdentityDenotTransformer {
26
25
def phaseName : String = " genericTuples"
27
26
28
27
override def transformApply (tree : tpd.Apply )(implicit ctx : Context ): tpd.Tree = {
29
- if (tree.symbol == defn.Tuple_cons ) transformTupleCons(tree)
28
+ if (tree.symbol == defn.DynamicTuple_dynamicCons ) transformTupleCons(tree)
30
29
else super .transformApply(tree)
31
30
}
32
31
32
+
33
+
33
34
// override def transformTypeApply(tree: tpd.TypeApply)(implicit ctx: Context): tpd.Tree = {
34
35
// if (tree.symbol == defn.NonEmptyTuple_tail) transformTupleTail(tree)
35
36
// else super.transformTypeApply(tree)
36
37
// }
37
38
38
39
private def transformTupleCons (tree : tpd.Apply )(implicit ctx : Context ): Tree = {
39
- val TypeApply (Select (qual, _), headType :: tailType :: Nil ) = tree.fun
40
+ val TypeApply (_, headType :: tailType :: Nil ) = tree.fun
41
+ val tail :: head :: Nil = tree.args
40
42
tupleTypes(tree.tpe) match {
41
43
case Some (tpes) =>
42
44
val size = tpes.size
@@ -46,21 +48,22 @@ class GenericTuples extends MiniPhase with IdentityDenotTransformer {
46
48
val tailType =
47
49
if (size == 1 ) defn.UnitType
48
50
else defn.TupleType (size - 1 ).appliedTo(tpes.tail)
49
- evalOnce(Typed (qual , TypeTree (tailType))) { tup =>
50
- val elements = tree.args. head :: (0 until size - 1 ).map(i => tup.select(nme.selectorName(i))).toList
51
+ evalOnce(Typed (tail , TypeTree (tailType))) { tup =>
52
+ val elements = head :: (0 until size - 1 ).map(i => tup.select(nme.selectorName(i))).toList
51
53
knownTupleFromElements(tpes, elements)
52
54
}
53
55
} else {
54
56
// val it = Iterator.single(head) ++ tail.asInstanceOf[Product].productIterator
55
57
// TupleN(it.next(), ..., it.next())
56
- val fullIterator = ref(defn.DynamicTuple_consIterator ).appliedToArgs(tree.args. head :: qual :: Nil )
58
+ val fullIterator = ref(defn.DynamicTuple_consIterator ).appliedToArgs(head :: tail :: Nil )
57
59
evalOnce(fullIterator) { it =>
58
60
knownTupleFromIterator(tpes.length, it).asInstance(tree.tpe)
59
61
}
60
62
}
61
63
case _ =>
62
- // DynamicTuple.dynamic_*:(tail, head)
63
- ref(defn.DynamicTupleModule ).select(" dynamic_*:" .toTermName).appliedToTypeTrees(tailType :: headType :: Nil ).appliedToArgs(qual :: tree.args).asInstance(tree.tpe)
64
+ // DynamicTuple.dynamicCons:(tail, head)
65
+ tree
66
+ // ref(defn.DynamicTupleModule).select("dynamicCons".toTermName).appliedToTypeTrees(tailType :: headType :: Nil).appliedToArgs(qual :: tree.args).asInstance(tree.tpe)
64
67
}
65
68
}
66
69
0 commit comments