@@ -13,7 +13,7 @@ object Expr {
1313 * To retain semantics the argument `ei` is bound as `val yi = ei` and by-name arguments to `def yi = ei`.
1414 * Some bindings may be elided as an early optimization.
1515 */
16- def betaReduce [T ](expr : Expr [T ])(using qctx : Quotes ): Expr [T ] =
16+ def betaReduce [T ](expr : Expr [T ])(using Quotes ): Expr [T ] =
1717 import qctx .reflect ._
1818 Term .betaReduce(Term .of(expr)) match
1919 case Some (expr1) => expr1.asExpr.asInstanceOf [Expr [T ]]
@@ -23,13 +23,14 @@ object Expr {
2323 * Given list of statements `s1 :: s2 :: ... :: Nil` and an expression `e` the resulting expression
2424 * will be equivalent to `'{ $s1; $s2; ...; $e }`.
2525 */
26- def block [T ](statements : List [Expr [Any ]], expr : Expr [T ])(using qctx : Quotes ): Expr [T ] = {
26+ def block [T ](statements : List [Expr [Any ]], expr : Expr [T ])(using Quotes ): Expr [T ] = {
2727 import qctx .reflect ._
2828 Block (statements.map(Term .of), Term .of(expr)).asExpr.asInstanceOf [Expr [T ]]
2929 }
3030
3131 /** Lift a value into an expression containing the construction of that value */
32- def apply [T ](x : T )(using qctx : Quotes , lift : Liftable [T ]): Expr [T ] = lift.toExpr(x)
32+ def apply [T ](x : T )(using lift : Liftable [T ])(using Quotes ): Expr [T ] =
33+ lift.toExpr(x)
3334
3435 /** Lifts this sequence of expressions into an expression of a sequence
3536 *
@@ -39,7 +40,8 @@ object Expr {
3940 * `'{ Seq($e1, $e2, ...) }` typed as an `Expr[Seq[T]]`
4041 * ```
4142 */
42- def ofSeq [T ](xs : Seq [Expr [T ]])(using tp : Type [T ], qctx : Quotes ): Expr [Seq [T ]] = Varargs (xs)
43+ def ofSeq [T ](xs : Seq [Expr [T ]])(using tp : Type [T ], qctx : Quotes ): Expr [Seq [T ]] =
44+ Varargs (xs)
4345
4446 /** Lifts this list of expressions into an expression of a list
4547 *
@@ -48,7 +50,7 @@ object Expr {
4850 * to an expression equivalent to
4951 * `'{ List($e1, $e2, ...) }` typed as an `Expr[List[T]]`
5052 */
51- def ofList [T ](xs : Seq [Expr [T ]])(using Type [T ], Quotes ): Expr [List [T ]] =
53+ def ofList [T ](xs : Seq [Expr [T ]])(using Type [T ])( using Quotes ): Expr [List [T ]] =
5254 if (xs.isEmpty) Expr (Nil ) else ' { List ($ {Varargs (xs)}: _* ) }
5355
5456 /** Lifts this sequence of expressions into an expression of a tuple
@@ -58,7 +60,7 @@ object Expr {
5860 * to an expression equivalent to
5961 * `'{ ($e1, $e2, ...) }` typed as an `Expr[Tuple]`
6062 */
61- def ofTupleFromSeq (seq : Seq [Expr [Any ]])(using qctx : Quotes ): Expr [Tuple ] = {
63+ def ofTupleFromSeq (seq : Seq [Expr [Any ]])(using Quotes ): Expr [Tuple ] = {
6264 seq.size match {
6365 case 0 => ' { Tuple () }
6466 case 1 => ofTupleFromSeq1(seq)
@@ -87,116 +89,116 @@ object Expr {
8789 }
8890 }
8991
90- private def ofTupleFromSeq1 (seq : Seq [Expr [Any ]])(using qctx : Quotes ): Expr [Tuple ] =
92+ private def ofTupleFromSeq1 (seq : Seq [Expr [Any ]])(using Quotes ): Expr [Tuple ] =
9193 seq match
9294 case Seq (' { $x1 : t1 }) => ' { Tuple1 ($x1) }
9395
94- private def ofTupleFromSeq2 (seq : Seq [Expr [Any ]])(using qctx : Quotes ): Expr [Tuple ] =
96+ private def ofTupleFromSeq2 (seq : Seq [Expr [Any ]])(using Quotes ): Expr [Tuple ] =
9597 seq match
9698 case Seq (' { $x1 : t1 }, ' { $x2 : t2 }) => ' { Tuple2 ($x1, $x2) }
9799
98- private def ofTupleFromSeq3 (seq : Seq [Expr [Any ]])(using qctx : Quotes ): Expr [Tuple ] =
100+ private def ofTupleFromSeq3 (seq : Seq [Expr [Any ]])(using Quotes ): Expr [Tuple ] =
99101 seq match
100102 case Seq (' { $x1 : t1 }, ' { $x2 : t2 }, ' { $x3 : t3 }) => ' { Tuple3 ($x1, $x2, $x3) }
101103
102- private def ofTupleFromSeq4 (seq : Seq [Expr [Any ]])(using qctx : Quotes ): Expr [Tuple ] =
104+ private def ofTupleFromSeq4 (seq : Seq [Expr [Any ]])(using Quotes ): Expr [Tuple ] =
103105 seq match
104106 case Seq (' { $x1 : t1 }, ' { $x2 : t2 }, ' { $x3 : t3 }, ' { $x4 : t4 }) =>
105107 ' { Tuple4 ($x1, $x2, $x3, $x4) }
106108
107- private def ofTupleFromSeq5 (seq : Seq [Expr [Any ]])(using qctx : Quotes ): Expr [Tuple ] =
109+ private def ofTupleFromSeq5 (seq : Seq [Expr [Any ]])(using Quotes ): Expr [Tuple ] =
108110 seq match
109111 case Seq (' { $x1 : t1 }, ' { $x2 : t2 }, ' { $x3 : t3 }, ' { $x4 : t4 }, ' { $x5 : t5 }) =>
110112 ' { Tuple5 ($x1, $x2, $x3, $x4, $x5) }
111113
112- private def ofTupleFromSeq6 (seq : Seq [Expr [Any ]])(using qctx : Quotes ): Expr [Tuple ] =
114+ private def ofTupleFromSeq6 (seq : Seq [Expr [Any ]])(using Quotes ): Expr [Tuple ] =
113115 seq match
114116 case Seq (' { $x1 : t1 }, ' { $x2 : t2 }, ' { $x3 : t3 }, ' { $x4 : t4 }, ' { $x5 : t5 }, ' { $x6 : t6 }) =>
115117 ' { Tuple6 ($x1, $x2, $x3, $x4, $x5, $x6) }
116118
117- private def ofTupleFromSeq7 (seq : Seq [Expr [Any ]])(using qctx : Quotes ): Expr [Tuple ] =
119+ private def ofTupleFromSeq7 (seq : Seq [Expr [Any ]])(using Quotes ): Expr [Tuple ] =
118120 seq match
119121 case Seq (' { $x1 : t1 }, ' { $x2 : t2 }, ' { $x3 : t3 }, ' { $x4 : t4 }, ' { $x5 : t5 }, ' { $x6 : t6 }, ' { $x7 : t7 }) =>
120122 ' { Tuple7 ($x1, $x2, $x3, $x4, $x5, $x6, $x7) }
121123
122- private def ofTupleFromSeq8 (seq : Seq [Expr [Any ]])(using qctx : Quotes ): Expr [Tuple ] =
124+ private def ofTupleFromSeq8 (seq : Seq [Expr [Any ]])(using Quotes ): Expr [Tuple ] =
123125 seq match
124126 case Seq (' { $x1 : t1 }, ' { $x2 : t2 }, ' { $x3 : t3 }, ' { $x4 : t4 }, ' { $x5 : t5 }, ' { $x6 : t6 }, ' { $x7 : t7 }, ' { $x8 : t8 }) =>
125127 ' { Tuple8 ($x1, $x2, $x3, $x4, $x5, $x6, $x7, $x8) }
126128
127- private def ofTupleFromSeq9 (seq : Seq [Expr [Any ]])(using qctx : Quotes ): Expr [Tuple ] =
129+ private def ofTupleFromSeq9 (seq : Seq [Expr [Any ]])(using Quotes ): Expr [Tuple ] =
128130 seq match
129131 case Seq (' { $x1 : t1 }, ' { $x2 : t2 }, ' { $x3 : t3 }, ' { $x4 : t4 }, ' { $x5 : t5 }, ' { $x6 : t6 }, ' { $x7 : t7 }, ' { $x8 : t8 }, ' { $x9 : t9 }) =>
130132 ' { Tuple9 ($x1, $x2, $x3, $x4, $x5, $x6, $x7, $x8, $x9) }
131133
132- private def ofTupleFromSeq10 (seq : Seq [Expr [Any ]])(using qctx : Quotes ): Expr [Tuple ] =
134+ private def ofTupleFromSeq10 (seq : Seq [Expr [Any ]])(using Quotes ): Expr [Tuple ] =
133135 seq match
134136 case Seq (' { $x1 : t1 }, ' { $x2 : t2 }, ' { $x3 : t3 }, ' { $x4 : t4 }, ' { $x5 : t5 }, ' { $x6 : t6 }, ' { $x7 : t7 }, ' { $x8 : t8 }, ' { $x9 : t9 }, ' { $x10 : t10 }) =>
135137 ' { Tuple10 ($x1, $x2, $x3, $x4, $x5, $x6, $x7, $x8, $x9, $x10) }
136138
137- private def ofTupleFromSeq11 (seq : Seq [Expr [Any ]])(using qctx : Quotes ): Expr [Tuple ] =
139+ private def ofTupleFromSeq11 (seq : Seq [Expr [Any ]])(using Quotes ): Expr [Tuple ] =
138140 seq match
139141 case Seq (' { $x1 : t1 }, ' { $x2 : t2 }, ' { $x3 : t3 }, ' { $x4 : t4 }, ' { $x5 : t5 }, ' { $x6 : t6 }, ' { $x7 : t7 }, ' { $x8 : t8 }, ' { $x9 : t9 }, ' { $x10 : t10 }, ' { $x11 : t11 }) =>
140142 ' { Tuple11 ($x1, $x2, $x3, $x4, $x5, $x6, $x7, $x8, $x9, $x10, $x11) }
141143
142- private def ofTupleFromSeq12 (seq : Seq [Expr [Any ]])(using qctx : Quotes ): Expr [Tuple ] =
144+ private def ofTupleFromSeq12 (seq : Seq [Expr [Any ]])(using Quotes ): Expr [Tuple ] =
143145 seq match
144146 case Seq (' { $x1 : t1 }, ' { $x2 : t2 }, ' { $x3 : t3 }, ' { $x4 : t4 }, ' { $x5 : t5 }, ' { $x6 : t6 }, ' { $x7 : t7 }, ' { $x8 : t8 }, ' { $x9 : t9 }, ' { $x10 : t10 }, ' { $x11 : t11 }, ' { $x12 : t12 }) =>
145147 ' { Tuple12 ($x1, $x2, $x3, $x4, $x5, $x6, $x7, $x8, $x9, $x10, $x11, $x12) }
146148
147- private def ofTupleFromSeq13 (seq : Seq [Expr [Any ]])(using qctx : Quotes ): Expr [Tuple ] =
149+ private def ofTupleFromSeq13 (seq : Seq [Expr [Any ]])(using Quotes ): Expr [Tuple ] =
148150 seq match
149151 case Seq (' { $x1 : t1 }, ' { $x2 : t2 }, ' { $x3 : t3 }, ' { $x4 : t4 }, ' { $x5 : t5 }, ' { $x6 : t6 }, ' { $x7 : t7 }, ' { $x8 : t8 }, ' { $x9 : t9 }, ' { $x10 : t10 }, ' { $x11 : t11 }, ' { $x12 : t12 }, ' { $x13 : t13 }) =>
150152 ' { Tuple13 ($x1, $x2, $x3, $x4, $x5, $x6, $x7, $x8, $x9, $x10, $x11, $x12, $x13) }
151153
152- private def ofTupleFromSeq14 (seq : Seq [Expr [Any ]])(using qctx : Quotes ): Expr [Tuple ] =
154+ private def ofTupleFromSeq14 (seq : Seq [Expr [Any ]])(using Quotes ): Expr [Tuple ] =
153155 seq match
154156 case Seq (' { $x1 : t1 }, ' { $x2 : t2 }, ' { $x3 : t3 }, ' { $x4 : t4 }, ' { $x5 : t5 }, ' { $x6 : t6 }, ' { $x7 : t7 }, ' { $x8 : t8 }, ' { $x9 : t9 }, ' { $x10 : t10 }, ' { $x11 : t11 }, ' { $x12 : t12 }, ' { $x13 : t13 }, ' { $x14 : t14 }) =>
155157 ' { Tuple14 ($x1, $x2, $x3, $x4, $x5, $x6, $x7, $x8, $x9, $x10, $x11, $x12, $x13, $x14) }
156158
157- private def ofTupleFromSeq15 (seq : Seq [Expr [Any ]])(using qctx : Quotes ): Expr [Tuple ] =
159+ private def ofTupleFromSeq15 (seq : Seq [Expr [Any ]])(using Quotes ): Expr [Tuple ] =
158160 seq match
159161 case Seq (' { $x1 : t1 }, ' { $x2 : t2 }, ' { $x3 : t3 }, ' { $x4 : t4 }, ' { $x5 : t5 }, ' { $x6 : t6 }, ' { $x7 : t7 }, ' { $x8 : t8 }, ' { $x9 : t9 }, ' { $x10 : t10 }, ' { $x11 : t11 }, ' { $x12 : t12 }, ' { $x13 : t13 }, ' { $x14 : t14 }, ' { $x15 : t15 }) =>
160162 ' { Tuple15 ($x1, $x2, $x3, $x4, $x5, $x6, $x7, $x8, $x9, $x10, $x11, $x12, $x13, $x14, $x15) }
161163
162- private def ofTupleFromSeq16 (seq : Seq [Expr [Any ]])(using qctx : Quotes ): Expr [Tuple ] =
164+ private def ofTupleFromSeq16 (seq : Seq [Expr [Any ]])(using Quotes ): Expr [Tuple ] =
163165 seq match
164166 case Seq (' { $x1 : t1 }, ' { $x2 : t2 }, ' { $x3 : t3 }, ' { $x4 : t4 }, ' { $x5 : t5 }, ' { $x6 : t6 }, ' { $x7 : t7 }, ' { $x8 : t8 }, ' { $x9 : t9 }, ' { $x10 : t10 }, ' { $x11 : t11 }, ' { $x12 : t12 }, ' { $x13 : t13 }, ' { $x14 : t14 }, ' { $x15 : t15 }, ' { $x16 : t16 }) =>
165167 ' { Tuple16 ($x1, $x2, $x3, $x4, $x5, $x6, $x7, $x8, $x9, $x10, $x11, $x12, $x13, $x14, $x15, $x16) }
166168
167- private def ofTupleFromSeq17 (seq : Seq [Expr [Any ]])(using qctx : Quotes ): Expr [Tuple ] =
169+ private def ofTupleFromSeq17 (seq : Seq [Expr [Any ]])(using Quotes ): Expr [Tuple ] =
168170 seq match
169171 case Seq (' { $x1 : t1 }, ' { $x2 : t2 }, ' { $x3 : t3 }, ' { $x4 : t4 }, ' { $x5 : t5 }, ' { $x6 : t6 }, ' { $x7 : t7 }, ' { $x8 : t8 }, ' { $x9 : t9 }, ' { $x10 : t10 }, ' { $x11 : t11 }, ' { $x12 : t12 }, ' { $x13 : t13 }, ' { $x14 : t14 }, ' { $x15 : t15 }, ' { $x16 : t16 }, ' { $x17 : t17 }) =>
170172 ' { Tuple17 ($x1, $x2, $x3, $x4, $x5, $x6, $x7, $x8, $x9, $x10, $x11, $x12, $x13, $x14, $x15, $x16, $x17) }
171173
172- private def ofTupleFromSeq18 (seq : Seq [Expr [Any ]])(using qctx : Quotes ): Expr [Tuple ] =
174+ private def ofTupleFromSeq18 (seq : Seq [Expr [Any ]])(using Quotes ): Expr [Tuple ] =
173175 seq match
174176 case Seq (' { $x1 : t1 }, ' { $x2 : t2 }, ' { $x3 : t3 }, ' { $x4 : t4 }, ' { $x5 : t5 }, ' { $x6 : t6 }, ' { $x7 : t7 }, ' { $x8 : t8 }, ' { $x9 : t9 }, ' { $x10 : t10 }, ' { $x11 : t11 }, ' { $x12 : t12 }, ' { $x13 : t13 }, ' { $x14 : t14 }, ' { $x15 : t15 }, ' { $x16 : t16 }, ' { $x17 : t17 }, ' { $x18 : t18 }) =>
175177 ' { Tuple18 ($x1, $x2, $x3, $x4, $x5, $x6, $x7, $x8, $x9, $x10, $x11, $x12, $x13, $x14, $x15, $x16, $x17, $x18) }
176178
177- private def ofTupleFromSeq19 (seq : Seq [Expr [Any ]])(using qctx : Quotes ): Expr [Tuple ] =
179+ private def ofTupleFromSeq19 (seq : Seq [Expr [Any ]])(using Quotes ): Expr [Tuple ] =
178180 seq match
179181 case Seq (' { $x1 : t1 }, ' { $x2 : t2 }, ' { $x3 : t3 }, ' { $x4 : t4 }, ' { $x5 : t5 }, ' { $x6 : t6 }, ' { $x7 : t7 }, ' { $x8 : t8 }, ' { $x9 : t9 }, ' { $x10 : t10 }, ' { $x11 : t11 }, ' { $x12 : t12 }, ' { $x13 : t13 }, ' { $x14 : t14 }, ' { $x15 : t15 }, ' { $x16 : t16 }, ' { $x17 : t17 }, ' { $x18 : t18 }, ' { $x19 : t19 }) =>
180182 ' { Tuple19 ($x1, $x2, $x3, $x4, $x5, $x6, $x7, $x8, $x9, $x10, $x11, $x12, $x13, $x14, $x15, $x16, $x17, $x18, $x19) }
181183
182- private def ofTupleFromSeq20 (seq : Seq [Expr [Any ]])(using qctx : Quotes ): Expr [Tuple ] =
184+ private def ofTupleFromSeq20 (seq : Seq [Expr [Any ]])(using Quotes ): Expr [Tuple ] =
183185 seq match
184186 case Seq (' { $x1 : t1 }, ' { $x2 : t2 }, ' { $x3 : t3 }, ' { $x4 : t4 }, ' { $x5 : t5 }, ' { $x6 : t6 }, ' { $x7 : t7 }, ' { $x8 : t8 }, ' { $x9 : t9 }, ' { $x10 : t10 }, ' { $x11 : t11 }, ' { $x12 : t12 }, ' { $x13 : t13 }, ' { $x14 : t14 }, ' { $x15 : t15 }, ' { $x16 : t16 }, ' { $x17 : t17 }, ' { $x18 : t18 }, ' { $x19 : t19 }, ' { $x20 : t20 }) =>
185187 ' { Tuple20 ($x1, $x2, $x3, $x4, $x5, $x6, $x7, $x8, $x9, $x10, $x11, $x12, $x13, $x14, $x15, $x16, $x17, $x18, $x19, $x20) }
186188
187- private def ofTupleFromSeq21 (seq : Seq [Expr [Any ]])(using qctx : Quotes ): Expr [Tuple ] =
189+ private def ofTupleFromSeq21 (seq : Seq [Expr [Any ]])(using Quotes ): Expr [Tuple ] =
188190 seq match
189191 case Seq (' { $x1 : t1 }, ' { $x2 : t2 }, ' { $x3 : t3 }, ' { $x4 : t4 }, ' { $x5 : t5 }, ' { $x6 : t6 }, ' { $x7 : t7 }, ' { $x8 : t8 }, ' { $x9 : t9 }, ' { $x10 : t10 }, ' { $x11 : t11 }, ' { $x12 : t12 }, ' { $x13 : t13 }, ' { $x14 : t14 }, ' { $x15 : t15 }, ' { $x16 : t16 }, ' { $x17 : t17 }, ' { $x18 : t18 }, ' { $x19 : t19 }, ' { $x20 : t20 }, ' { $x21 : t21 }) =>
190192 ' { Tuple21 ($x1, $x2, $x3, $x4, $x5, $x6, $x7, $x8, $x9, $x10, $x11, $x12, $x13, $x14, $x15, $x16, $x17, $x18, $x19, $x20, $x21) }
191193
192- private def ofTupleFromSeq22 (seq : Seq [Expr [Any ]])(using qctx : Quotes ): Expr [Tuple ] =
194+ private def ofTupleFromSeq22 (seq : Seq [Expr [Any ]])(using Quotes ): Expr [Tuple ] =
193195 seq match
194196 case Seq (' { $x1 : t1 }, ' { $x2 : t2 }, ' { $x3 : t3 }, ' { $x4 : t4 }, ' { $x5 : t5 }, ' { $x6 : t6 }, ' { $x7 : t7 }, ' { $x8 : t8 }, ' { $x9 : t9 }, ' { $x10 : t10 }, ' { $x11 : t11 }, ' { $x12 : t12 }, ' { $x13 : t13 }, ' { $x14 : t14 }, ' { $x15 : t15 }, ' { $x16 : t16 }, ' { $x17 : t17 }, ' { $x18 : t18 }, ' { $x19 : t19 }, ' { $x20 : t20 }, ' { $x21 : t21 }, ' { $x22 : t22 }) =>
195197 ' { Tuple22 ($x1, $x2, $x3, $x4, $x5, $x6, $x7, $x8, $x9, $x10, $x11, $x12, $x13, $x14, $x15, $x16, $x17, $x18, $x19, $x20, $x21, $x22) }
196198
197199
198200 /** Given a tuple of the form `(Expr[A1], ..., Expr[An])`, outputs a tuple `Expr[(A1, ..., An)]`. */
199- def ofTuple [T <: Tuple : Tuple .IsMappedBy [Expr ]: Type ](tup : T )(using qctx : Quotes ): Expr [Tuple .InverseMap [T , Expr ]] = {
201+ def ofTuple [T <: Tuple : Tuple .IsMappedBy [Expr ]: Type ](tup : T )(using Quotes ): Expr [Tuple .InverseMap [T , Expr ]] = {
200202 val elems : Seq [Expr [Any ]] = tup.asInstanceOf [Product ].productIterator.toSeq.asInstanceOf [Seq [Expr [Any ]]]
201203 ofTupleFromSeq(elems).asExprOf[Tuple .InverseMap [T , Expr ]]
202204 }
@@ -209,7 +211,7 @@ object Expr {
209211 * @param tpe quoted type of the implicit parameter
210212 * @param qctx current context
211213 */
212- def summon [T ](using tpe : Type [T ])(using qctx : Quotes ): Option [Expr [T ]] = {
214+ def summon [T ](using Type [T ])(using Quotes ): Option [Expr [T ]] = {
213215 import qctx .reflect ._
214216 Implicits .search(TypeRepr .of[T ]) match {
215217 case iss : ImplicitSearchSuccess => Some (iss.tree.asExpr.asInstanceOf [Expr [T ]])
0 commit comments