Skip to content

Fixed given imports and removed reference to toExpr extension (#7608) #7611

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions docs/docs/reference/metaprogramming/macros.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ Here’s a compiler that maps an expression given in the interpreted
language to quoted Scala code of type `Expr[Int]`.
The compiler takes an environment that maps variable names to Scala `Expr`s.
```scala
import given scala.quoted._
import scala.quoted.{given, _}

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

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

Expand Down