File tree 5 files changed +6
-28
lines changed
compiler/src/dotty/tools/dotc
tests/run-with-compiler/staged-tuples 5 files changed +6
-28
lines changed Original file line number Diff line number Diff line change @@ -809,7 +809,6 @@ class Definitions {
809
809
lazy val DynamicTuple_concatIterator : Symbol = DynamicTupleModule .requiredMethod(" concatIterator" )
810
810
lazy val DynamicTuple_dynamicApply : Symbol = DynamicTupleModule .requiredMethod(" dynamicApply" )
811
811
lazy val DynamicTuple_dynamicCons : Symbol = DynamicTupleModule .requiredMethod(" dynamicCons" )
812
- lazy val DynamicTuple_dynamicHead : Symbol = DynamicTupleModule .requiredMethod(" dynamicHead" )
813
812
lazy val DynamicTuple_dynamicSize : Symbol = DynamicTupleModule .requiredMethod(" dynamicSize" )
814
813
lazy val DynamicTuple_dynamicTail : Symbol = DynamicTupleModule .requiredMethod(" dynamicTail" )
815
814
lazy val DynamicTuple_dynamicConcat : Symbol = DynamicTupleModule .requiredMethod(" dynamicConcat" )
Original file line number Diff line number Diff line change @@ -26,7 +26,6 @@ class GenericTuples extends MiniPhase with IdentityDenotTransformer {
26
26
27
27
override def transformApply (tree : tpd.Apply )(implicit ctx : Context ): tpd.Tree = {
28
28
if (tree.symbol == defn.DynamicTuple_dynamicCons ) transformTupleCons(tree)
29
- else if (tree.symbol == defn.DynamicTuple_dynamicHead ) transformTupleHead(tree)
30
29
else if (tree.symbol == defn.DynamicTuple_dynamicTail ) transformTupleTail(tree)
31
30
else if (tree.symbol == defn.DynamicTuple_dynamicSize ) transformTupleSize(tree)
32
31
else if (tree.symbol == defn.DynamicTuple_dynamicConcat ) transformTupleConcat(tree)
@@ -96,23 +95,6 @@ class GenericTuples extends MiniPhase with IdentityDenotTransformer {
96
95
}
97
96
}
98
97
99
- private def transformTupleHead (tree : tpd.Apply )(implicit ctx : Context ): Tree = {
100
- val Apply (TypeApply (_, tpt :: Nil ), tup :: Nil ) = tree
101
- tupleTypes(tpt.tpe) match { // TODO tupleBoundedTypes
102
- case Some (tpes) =>
103
- if (tpes.size <= Definitions .MaxTupleArity ) {
104
- // tup._1
105
- Typed (tup, TypeTree (defn.tupleType(tpes))).select(nme.selectorName(0 ))
106
- } else {
107
- // tup.asInstanceOf[TupleXXL].productElement(0)
108
- tup.asInstance(defn.TupleXXLType ).select(nme.productElement).appliedTo(Literal (Constant (0 )))
109
- }
110
- case None =>
111
- // DynamicTuple.dynamicHead(tup)
112
- tree
113
- }
114
- }
115
-
116
98
private def transformTupleSize (tree : tpd.Apply )(implicit ctx : Context ): Tree = {
117
99
tree.tpe.tryNormalize match {
118
100
case tp : ConstantType => Literal (tp.value)
Original file line number Diff line number Diff line change @@ -66,14 +66,15 @@ object Tuple {
66
66
sealed trait NonEmptyTuple extends Tuple {
67
67
import Tuple ._
68
68
69
+ inline def apply [This >: this .type <: NonEmptyTuple ](n : Int ): Elem [This , n.type ] =
70
+ DynamicTuple .dynamicApply[This , n.type ](this , n)
71
+
69
72
inline def head [This >: this .type <: NonEmptyTuple ]: Head [This ] =
70
- DynamicTuple .dynamicHead [This ](this )
73
+ DynamicTuple .dynamicApply [This , 0 ](this , 0 )
71
74
72
75
inline def tail [This >: this .type <: NonEmptyTuple ]: Tail [This ] =
73
76
DynamicTuple .dynamicTail[This ](this )
74
77
75
- inline def apply [This >: this .type <: NonEmptyTuple ](n : Int ): Elem [This , n.type ] =
76
- DynamicTuple .dynamicApply[This , n.type ](this , n)
77
78
}
78
79
79
80
@ showAsInfix
Original file line number Diff line number Diff line change @@ -226,9 +226,6 @@ object DynamicTuple {
226
226
case self : Product => self.productArity.asInstanceOf [Size [This ]]
227
227
}
228
228
229
- def dynamicHead [This <: NonEmptyTuple ] (self : This ): Head [This ] =
230
- self.asInstanceOf [Product ].productElement(0 ).asInstanceOf [Head [This ]]
231
-
232
229
def dynamicTail [This <: NonEmptyTuple ] (self : This ): Tail [This ] = {
233
230
type Result = Tail [This ]
234
231
val res = (self : Any ) match {
@@ -245,7 +242,6 @@ object DynamicTuple {
245
242
type Result = Elem [This , N ]
246
243
val res = (self : Any ) match {
247
244
case self : Unit => throw new IndexOutOfBoundsException (n.toString)
248
- case self : TupleXXL => self.elems(n)
249
245
case self : Product => self.productElement(n)
250
246
}
251
247
res.asInstanceOf [Result ]
Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ object StagedTuple {
79
79
}
80
80
81
81
def headStaged [Tup <: NonEmptyTuple : Type ](tup : Expr [Tup ], size : Option [Int ]): Expr [Head [Tup ]] = {
82
- if (! specialize) ' {dynamicHead ($tup)}
82
+ if (! specialize) ' {dynamicApply ($tup, 0 )}
83
83
else {
84
84
val resVal = size match {
85
85
case Some (1 ) =>
@@ -95,7 +95,7 @@ object StagedTuple {
95
95
case Some (n) if n > MaxSpecialized =>
96
96
' {$ {tup.as[TupleXXL ] }.elems(0 )}
97
97
case None =>
98
- ' {dynamicHead ($tup)}
98
+ ' {dynamicApply ($tup, 0 )}
99
99
}
100
100
resVal.as[Head [Tup ]]
101
101
}
You can’t perform that action at this time.
0 commit comments