@@ -16,14 +16,14 @@ class Expr[+T] private[scala] {
1616 * Returns `None` if the expression does not contain a value or contains side effects.
1717 * Otherwise returns the `Some` of the value.
1818 */
19- final def getValue [U >: T ](given qctx : QuoteContext , valueOf : ValueOfExpr [U ]): Option [U ] = valueOf(this )
19+ final def getValue [U >: T ](using qctx : QuoteContext , valueOf : ValueOfExpr [U ]): Option [U ] = valueOf(this )
2020
2121 /** Return the value of this expression.
2222 *
2323 * Emits an error error and throws if the expression does not contain a value or contains side effects.
2424 * Otherwise returns the value.
2525 */
26- final def value [U >: T ](given qctx : QuoteContext , valueOf : ValueOfExpr [U ]): U =
26+ final def value [U >: T ](using qctx : QuoteContext , valueOf : ValueOfExpr [U ]): U =
2727 valueOf(this ).getOrElse(qctx.throwError(s " Expected a known value. \n\n The value of: $show\n could not be recovered using $valueOf" , this ))
2828
2929 /** Pattern matches `this` against `that`. Effectively performing a deep equality check.
@@ -34,15 +34,15 @@ class Expr[+T] private[scala] {
3434 * case _ => false
3535 * ```
3636 */
37- final def matches (that : Expr [Any ])(given qctx : QuoteContext ): Boolean =
37+ final def matches (that : Expr [Any ])(using qctx : QuoteContext ): Boolean =
3838 ! scala.internal.quoted.Expr .unapply[Unit , Unit ](this )(given that , false , qctx).isEmpty
3939
4040}
4141
4242object Expr {
4343
4444 /** Converts a tuple `(T1, ..., Tn)` to `(Expr[T1], ..., Expr[Tn])` */
45- type TupleOfExpr [Tup <: Tuple ] = Tuple .Map [Tup , [X ] =>> ( given QuoteContext ) => Expr [X ]]
45+ type TupleOfExpr [Tup <: Tuple ] = Tuple .Map [Tup , [X ] =>> QuoteContext ? => Expr [X ]]
4646
4747 /** `Expr.betaReduce(f)(x1, ..., xn)` is functionally the same as `'{($f)($x1, ..., $xn)}`, however it optimizes this call
4848 * by returning the result of beta-reducing `f(x1, ..., xn)` if `f` is a known lambda expression.
@@ -52,7 +52,7 @@ object Expr {
5252 * Expr.betaReduce(_): Expr[(T1, ..., Tn) => R] => ((Expr[T1], ..., Expr[Tn]) => Expr[R])
5353 * ```
5454 */
55- def betaReduce [F , Args <: Tuple , R , G ](f : Expr [F ])(given tf : TupledFunction [F , Args => R ], tg : TupledFunction [G , TupleOfExpr [Args ] => Expr [R ]], qctx : QuoteContext ): G = {
55+ def betaReduce [F , Args <: Tuple , R , G ](f : Expr [F ])(using tf : TupledFunction [F , Args => R ], tg : TupledFunction [G , TupleOfExpr [Args ] => Expr [R ]], qctx : QuoteContext ): G = {
5656 import qctx .tasty .{_ , given }
5757 tg.untupled(args => qctx.tasty.internal.betaReduce(f.unseal, args.toArray.toList.map(_.asInstanceOf [QuoteContext => Expr [_]](qctx).unseal)).seal.asInstanceOf [Expr [R ]])
5858 }
@@ -62,22 +62,22 @@ object Expr {
6262 *
6363 * `Expr.betaReduceGiven` distributes applications of `Expr` over function arrows
6464 * ```scala
65- * Expr.betaReduceGiven(_): Expr[(given T1, ..., Tn) => R] => ((Expr[T1], ..., Expr[Tn]) => Expr[R])
65+ * Expr.betaReduceGiven(_): Expr[(T1, ..., Tn) ? => R] => ((Expr[T1], ..., Expr[Tn]) => Expr[R])
6666 * ```
6767 */
68- def betaReduceGiven [F , Args <: Tuple , R , G ](f : Expr [F ])(given tf : TupledFunction [F , ( given Args ) => R ], tg : TupledFunction [G , TupleOfExpr [Args ] => Expr [R ]], qctx : QuoteContext ): G = {
68+ def betaReduceGiven [F , Args <: Tuple , R , G ](f : Expr [F ])(using tf : TupledFunction [F , Args ? => R ], tg : TupledFunction [G , TupleOfExpr [Args ] => Expr [R ]], qctx : QuoteContext ): G = {
6969 import qctx .tasty .{_ , given }
7070 tg.untupled(args => qctx.tasty.internal.betaReduce(f.unseal, args.toArray.toList.map(_.asInstanceOf [QuoteContext => Expr [_]](qctx).unseal)).seal.asInstanceOf [Expr [R ]])
7171 }
7272
7373 /** Returns a null expresssion equivalent to `'{null}` */
74- def nullExpr : ( given QuoteContext ) => Expr [Null ] = ( given qctx ) => {
74+ def nullExpr : QuoteContext ? => Expr [Null ] = qctx ? => {
7575 import qctx .tasty .{_ , given }
7676 Literal (Constant (null )).seal.asInstanceOf [Expr [Null ]]
7777 }
7878
7979 /** Returns a unit expresssion equivalent to `'{}` or `'{()}` */
80- def unitExpr : ( given QuoteContext ) => Expr [Unit ] = ( given qctx ) => {
80+ def unitExpr : QuoteContext ? => Expr [Unit ] = qctx ? => {
8181 import qctx .tasty .{_ , given }
8282 Literal (Constant (())).seal.asInstanceOf [Expr [Unit ]]
8383 }
@@ -86,13 +86,13 @@ object Expr {
8686 * Given list of statements `s1 :: s2 :: ... :: Nil` and an expression `e` the resulting expression
8787 * will be equivalent to `'{ $s1; $s2; ...; $e }`.
8888 */
89- def block [T ](statements : List [Expr [_]], expr : Expr [T ])(given qctx : QuoteContext ): Expr [T ] = {
89+ def block [T ](statements : List [Expr [_]], expr : Expr [T ])(using qctx : QuoteContext ): Expr [T ] = {
9090 import qctx .tasty .{_ , given }
9191 Block (statements.map(_.unseal), expr.unseal).seal.asInstanceOf [Expr [T ]]
9292 }
9393
9494 /** Lift a value into an expression containing the construction of that value */
95- def apply [T : Liftable ](x : T )(given QuoteContext ): Expr [T ] = summon[Liftable [T ]].toExpr(x)
95+ def apply [T : Liftable ](x : T )(using qctx : QuoteContext ): Expr [T ] = summon[Liftable [T ]].toExpr(x)
9696
9797 /** Lifts this sequence of expressions into an expression of a sequence
9898 *
@@ -106,7 +106,7 @@ object Expr {
106106 * '{ List(${Expr.ofSeq(List(1, 2, 3))}: _*) } // equvalent to '{ List(1, 2, 3) }
107107 * ```
108108 */
109- def ofSeq [T ](xs : Seq [Expr [T ]])(given tp : Type [T ], qctx : QuoteContext ): Expr [Seq [T ]] = {
109+ def ofSeq [T ](xs : Seq [Expr [T ]])(using tp : Type [T ], qctx : QuoteContext ): Expr [Seq [T ]] = {
110110 import qctx .tasty .{_ , given }
111111 Repeated (xs.map(_.unseal).toList, tp.unseal).seal.asInstanceOf [Expr [Seq [T ]]]
112112 }
@@ -119,7 +119,7 @@ object Expr {
119119 * to an expression equivalent to
120120 * `'{ List($e1, $e2, ...) }` typed as an `Expr[List[T]]`
121121 */
122- def ofList [T ](xs : Seq [Expr [T ]])(given Type [T ], QuoteContext ): Expr [List [T ]] =
122+ def ofList [T ](xs : Seq [Expr [T ]])(using Type [T ], QuoteContext ): Expr [List [T ]] =
123123 if (xs.isEmpty) ' { Nil } else ' { List ($ {ofSeq(xs)}: _* ) }
124124
125125 /** Lifts this sequence of expressions into an expression of a tuple
@@ -129,7 +129,7 @@ object Expr {
129129 * to an expression equivalent to
130130 * `'{ ($e1, $e2, ...) }` typed as an `Expr[Tuple]`
131131 */
132- def ofTuple (seq : Seq [Expr [_]])(given QuoteContext ): Expr [Tuple ] = {
132+ def ofTuple (seq : Seq [Expr [_]])(using qctx : QuoteContext ): Expr [Tuple ] = {
133133 seq match {
134134 case Seq () =>
135135 unitExpr
@@ -183,7 +183,7 @@ object Expr {
183183 }
184184
185185 /** Given a tuple of the form `(Expr[A1], ..., Expr[An])`, outputs a tuple `Expr[(A1, ..., An)]`. */
186- def ofTuple [T <: Tuple : Tuple .IsMappedBy [Expr ]: Type ](tup : T ) ( given qctx : QuoteContext ): Expr [Tuple .InverseMap [T , Expr ]] = {
186+ def ofTuple [T <: Tuple : Tuple .IsMappedBy [Expr ]: Type ](tup : T )( using qctx : QuoteContext ): Expr [Tuple .InverseMap [T , Expr ]] = {
187187 import qctx .tasty .{_ , given }
188188 val elems : Seq [Expr [_]] = tup.asInstanceOf [Product ].productIterator.toSeq.asInstanceOf [Seq [Expr [_]]]
189189 ofTuple(elems).cast[Tuple .InverseMap [T , Expr ]]
0 commit comments