@@ -4,18 +4,19 @@ import scala.quoted._
4
4
5
5
import scala .runtime .TupleXXL
6
6
7
+ import scala .runtime .Tuple .MaxSpecialized
8
+
7
9
object StagedTuple {
8
10
import Tuple .Concat
9
11
import Tuple .Head
10
12
import Tuple .Tail
11
13
import Tuple .Size
12
14
import Tuple .Elem
13
- import scala .runtime .DynamicTuple ._
14
15
15
16
private final val specialize = true
16
17
17
18
def toArrayStaged (tup : Expr [Tuple ], size : Option [Int ])(using QuoteContext ): Expr [Array [Object ]] = {
18
- if (! specialize) ' {dynamicToArray ($tup)}
19
+ if (! specialize) ' {scala.runtime. Tuple .toArray ($tup)}
19
20
else size match {
20
21
case Some (0 ) =>
21
22
' {Array .emptyObjectArray}
@@ -30,12 +31,12 @@ object StagedTuple {
30
31
case Some (n) =>
31
32
' { $ {tup.as[TupleXXL ]}.toArray }
32
33
case None =>
33
- ' {dynamicToArray ($tup)}
34
+ ' {scala.runtime. Tuple .toArray ($tup)}
34
35
}
35
36
}
36
37
37
38
def fromArrayStaged [T <: Tuple : Type ](xs : Expr [Array [Object ]], size : Option [Int ])(using QuoteContext ): Expr [T ] = {
38
- if (! specialize) ' {dynamicFromArray[ T ] ($xs)}
39
+ if (! specialize) ' {scala.runtime. Tuple .fromArray ($xs)}.as[ T ]
39
40
else xs.bind { xs =>
40
41
val tup : Expr [Any ] = size match {
41
42
case Some (0 ) => ' {}
@@ -62,24 +63,24 @@ object StagedTuple {
62
63
case Some (21 ) => ' {Tuple21 ($xs(0 ), $xs(1 ), $xs(2 ), $xs(3 ), $xs(4 ), $xs(5 ), $xs(6 ), $xs(7 ), $xs(8 ), $xs(9 ), $xs(10 ), $xs(11 ), $xs(12 ), $xs(13 ), $xs(14 ), $xs(15 ), $xs(16 ), $xs(17 ), $xs(18 ), $xs(19 ), $xs(20 ))}
63
64
case Some (22 ) => ' {Tuple22 ($xs(0 ), $xs(1 ), $xs(2 ), $xs(3 ), $xs(4 ), $xs(5 ), $xs(6 ), $xs(7 ), $xs(8 ), $xs(9 ), $xs(10 ), $xs(11 ), $xs(12 ), $xs(13 ), $xs(14 ), $xs(15 ), $xs(16 ), $xs(17 ), $xs(18 ), $xs(19 ), $xs(20 ), $xs(21 ))}
64
65
case Some (_) => ' {TupleXXL ($xs)}
65
- case None => ' {dynamicFromArray[ T ] ($xs)}
66
+ case None => ' {scala.runtime. Tuple .fromArray ($xs)}
66
67
}
67
68
tup.as[T ]
68
69
}
69
70
}
70
71
71
72
def sizeStaged [Res <: Int : Type ](tup : Expr [Tuple ], size : Option [Int ])(using QuoteContext ): Expr [Res ] = {
72
73
val res =
73
- if (! specialize) ' {dynamicSize ($tup)}
74
+ if (! specialize) ' {scala.runtime. Tuple .size ($tup)}
74
75
else size match {
75
76
case Some (n) => Expr (n)
76
- case None => ' {dynamicSize ($tup)}
77
+ case None => ' {scala.runtime. Tuple .size ($tup)}
77
78
}
78
79
res.as[Res ]
79
80
}
80
81
81
82
def headStaged [Tup <: NonEmptyTuple : Type ](tup : Expr [Tup ], size : Option [Int ])(using QuoteContext ): Expr [Head [Tup ]] = {
82
- if (! specialize) ' {dynamicApply[ Tup , 0 ] ($tup, 0 )}
83
+ if (! specialize) ' {scala.runtime. Tuple .apply ($tup, 0 )}.as[ Head [ Tup ]]
83
84
else {
84
85
val resVal = size match {
85
86
case Some (1 ) =>
@@ -95,14 +96,14 @@ object StagedTuple {
95
96
case Some (n) if n > MaxSpecialized =>
96
97
' {$ {tup.as[TupleXXL ] }.elems(0 )}
97
98
case None =>
98
- ' {dynamicApply ($tup, 0 )}
99
+ ' {scala.runtime. Tuple .apply ($tup, 0 )}
99
100
}
100
101
resVal.as[Head [Tup ]]
101
102
}
102
103
}
103
104
104
105
def tailStaged [Tup <: NonEmptyTuple : Type ](tup : Expr [Tup ], size : Option [Int ])(using QuoteContext ): Expr [Tail [Tup ]] = {
105
- if (! specialize) ' {dynamicTail[ Tup ] ($tup)}
106
+ if (! specialize) ' {scala.runtime. Tuple .tail ($tup)}.as[ Tail [ Tup ]]
106
107
else {
107
108
val res = size match {
108
109
case Some (1 ) =>
@@ -119,21 +120,21 @@ object StagedTuple {
119
120
val arr = toArrayStaged(tup, size)
120
121
fromArrayStaged[Tail [Tup ]](' { $arr.tail }, Some (n - 1 ))
121
122
case None =>
122
- ' {dynamicTail ($tup)}
123
+ ' {scala.runtime. Tuple .tail ($tup)}
123
124
}
124
125
res.as[Tail [Tup ]]
125
126
}
126
127
}
127
128
128
129
def applyStaged [Tup <: NonEmptyTuple : Type , N <: Int : Type ](tup : Expr [Tup ], size : Option [Int ], n : Expr [N ], nValue : Option [Int ])(using qctx : QuoteContext ): Expr [Elem [Tup , N ]] = {
129
130
130
- if (! specialize) ' {dynamicApply ($tup, $n)}
131
+ if (! specialize) ' {scala.runtime. Tuple .apply ($tup, $n)}.as[ Elem [ Tup , N ]]
131
132
else {
132
133
def fallbackApply (): Expr [Elem [Tup , N ]] = nValue match {
133
134
case Some (n) =>
134
135
qctx.error(" index out of bounds: " + n, tup)
135
136
' { throw new IndexOutOfBoundsException ($ {Expr (n.toString)}) }
136
- case None => ' {dynamicApply ($tup, $n)}
137
+ case None => ' {scala.runtime. Tuple .apply ($tup, $n)}.as[ Elem [ Tup , N ]]
137
138
}
138
139
val res = size match {
139
140
case Some (1 ) =>
@@ -185,7 +186,7 @@ object StagedTuple {
185
186
}
186
187
187
188
def consStaged [T <: Tuple & Singleton : Type , H : Type ](self : Expr [T ], x : Expr [H ], tailSize : Option [Int ])(using QuoteContext ): Expr [H *: T ] =
188
- if (! specialize) ' {dynamicCons[ H , T ] ($x, $self)}
189
+ if (! specialize) ' {scala.runtime. Tuple .cons ($x, $self)}.as[ H *: T ]
189
190
else {
190
191
val res = tailSize match {
191
192
case Some (0 ) =>
@@ -199,13 +200,13 @@ object StagedTuple {
199
200
case Some (4 ) =>
200
201
self.as[Tuple4 [_, _, _, _]].bind(t => ' {Tuple5 ($x, $t._1, $t._2, $t._3, $t._4)})
201
202
case _ =>
202
- ' {dynamicCons[ H , T ] ($x, $self)}
203
+ ' {scala.runtime. Tuple .cons ($x, $self)}
203
204
}
204
205
res.as[H *: T ]
205
206
}
206
207
207
208
def concatStaged [Self <: Tuple & Singleton : Type , That <: Tuple & Singleton : Type ](self : Expr [Self ], selfSize : Option [Int ], that : Expr [That ], thatSize : Option [Int ])(using QuoteContext ): Expr [Concat [Self , That ]] = {
208
- if (! specialize) ' {dynamicConcat[ Self , That ] ($self, $that)}
209
+ if (! specialize) ' {scala.runtime. Tuple .concat ($self, $that)}.as[ Concat [ Self , That ]]
209
210
else {
210
211
def genericConcat (xs : Expr [Tuple ], ys : Expr [Tuple ]): Expr [Tuple ] =
211
212
// TODO remove ascriptions when #6126 is fixed
@@ -247,7 +248,7 @@ object StagedTuple {
247
248
if (thatSize.contains(0 )) self
248
249
else genericConcat(self, that)
249
250
case None =>
250
- ' {dynamicConcat ($self, $that)}
251
+ ' {scala.runtime. Tuple .concat ($self, $that)}
251
252
}
252
253
res.as[Concat [Self , That ]]
253
254
}
0 commit comments