@@ -375,8 +375,8 @@ object Macros {
375
375
inline def assert (inline expr : Boolean ): Unit =
376
376
$ { assertImpl(' expr ) }
377
377
378
- def assertImpl (expr : Expr [Boolean ]) =
379
- ' { if ! ($expr) then throw new AssertionError (" failed assertion: " + $ {expr.show}) }
378
+ def assertImpl (expr : Expr [Boolean ])( using QuoteContext ) =
379
+ ' { if ! ($expr) then throw new AssertionError (" failed assertion: " + $ {expr.show}) } // autolift is applied
380
380
}
381
381
382
382
object App {
@@ -502,7 +502,7 @@ function `f` and one `sum` that performs a sum by delegating to `map`.
502
502
503
503
``` scala
504
504
object Macros {
505
- def map [T ](arr : Expr [Array [T ]], f : Expr [T ] => Expr [Unit ])(implicit t : Type [T ]): Expr [Unit ] = ' {
505
+ def map [T ](arr : Expr [Array [T ]], f : Expr [T ] => Expr [Unit ])(using t : Type [T ], qctx : QuoteContext ): Expr [Unit ] = ' {
506
506
var i : Int = 0
507
507
while (i < ($arr).length) {
508
508
val element : $t = ($arr)(i)
@@ -511,7 +511,7 @@ object Macros {
511
511
}
512
512
}
513
513
514
- def sum (arr : Expr [Array [Int ]]): Expr [Int ] = ' {
514
+ def sum (arr : Expr [Array [Int ]])( using QuoteContext ) : Expr [Int ] = ' {
515
515
var sum = 0
516
516
$ { map(arr, x => ' {sum += $x}) }
517
517
sum
@@ -719,7 +719,7 @@ This might be used to then perform an implicit search as in:
719
719
``` scala
720
720
inline def (inline sc : StringContext ).showMe(inline args : Any * ): String = $ { showMeExpr(' sc , ' args ) }
721
721
722
- private def showMeExpr (sc : Expr [StringContext ], argsExpr : Expr [Seq [Any ]])(using qctx : QuoteContext ): Expr [String ] = {
722
+ private def showMeExpr (sc : Expr [StringContext ], argsExpr : Expr [Seq [Any ]])(using QuoteContext ): Expr [String ] = {
723
723
argsExpr match {
724
724
case Varargs (argExprs) =>
725
725
val argShowedExprs = argExprs.map {
@@ -765,7 +765,7 @@ the subxpression of type `Expr[Int]` is bound to `body` as an `Expr[Int => Int]`
765
765
``` scala
766
766
inline def eval (inline e : Int ): Int = $ { evalExpr(' e ) }
767
767
768
- private def evalExpr (using QuoteContext )( e : Expr [Int ]): Expr [Int ] = {
768
+ private def evalExpr (e : Expr [Int ])( using QuoteContext ): Expr [Int ] = {
769
769
e match {
770
770
case ' { val y : Int = $x; $body(y): Int } =>
771
771
// body: Expr[Int => Int] where the argument represents references to y
0 commit comments