From 373fe42c0637a809c2a1c4d5b170f120f3e27018 Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Sat, 23 Nov 2019 21:43:45 +0000 Subject: [PATCH] Fix #7608: Additional corrections to given imports and toExpr Fixed 2 outdated given imports and removed 1 obsolete reference to toExpr ext. --- docs/docs/reference/metaprogramming/macros.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/docs/reference/metaprogramming/macros.md b/docs/docs/reference/metaprogramming/macros.md index 85d39e304560..ef717ee8d57a 100644 --- a/docs/docs/reference/metaprogramming/macros.md +++ b/docs/docs/reference/metaprogramming/macros.md @@ -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) => @@ -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.