Skip to content

Commit c9e38db

Browse files
committed
fixed given imports and removed reference to toExpr extension
1 parent 120f423 commit c9e38db

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

docs/docs/reference/metaprogramming/macros.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ Here’s a compiler that maps an expression given in the interpreted
220220
language to quoted Scala code of type `Expr[Int]`.
221221
The compiler takes an environment that maps variable names to Scala `Expr`s.
222222
```scala
223-
import given scala.quoted._
223+
import scala.quoted.{given, _}
224224

225225
def compile(e: Exp, env: Map[String, Expr[Int]]): Expr[Int] = e match {
226226
case Num(n) =>
@@ -308,10 +308,10 @@ def showExpr[T](expr: Expr[T]): Expr[String] = {
308308
}
309309
```
310310
That is, the `showExpr` method converts its `Expr` argument to a string (`code`), and lifts
311-
the result back to an `Expr[String]` using the `toExpr` method.
311+
the result back to an `Expr[String]` using `Expr.apply`.
312312

313-
**Note**: the `toExpr` extension method can be ommited by importing an implicit
314-
conversion with `import given scala.quoted.autolift._`. The programmer is able to
313+
**Note**: Lifting `String` to `Expr[String]` using `Expr(code)` can be ommited by importing an implicit
314+
conversion with `import scala.quoted.autolift.given`. The programmer is able to
315315
declutter slightly the code at the cost of readable _phase distinction_ between
316316
stages.
317317

0 commit comments

Comments
 (0)