Skip to content

Commit f363bd2

Browse files
Merge pull request #7267 from dotty-staging/move-quoted-lifters-inot-expr
Replace quoted `toExpr` with `Expr.apply`
2 parents 8258caf + 456c8b3 commit f363bd2

File tree

81 files changed

+223
-220
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+223
-220
lines changed

docs/docs/reference/changed-features/numeric-literals.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ implementation method `fromDigitsImpl`. Here is its definition:
206206
case Const(ds) =>
207207
try {
208208
val BigFloat(m, e) = apply(ds)
209-
'{BigFloat(${m.toExpr}, ${e.toExpr})}
209+
'{BigFloat(${Expr(m)}, ${Expr(e)})}
210210
}
211211
catch {
212212
case ex: FromDigits.FromDigitsException =>

docs/docs/reference/metaprogramming/macros.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ import given scala.quoted._
228228

229229
def compile(e: Exp, env: Map[String, Expr[Int]]): Expr[Int] = e match {
230230
case Num(n) =>
231-
n.toExpr
231+
Expr(n)
232232
case Plus(e1, e2) =>
233233
'{ ${ compile(e1, env) } + ${ compile(e2, env) } }
234234
case Var(x) =>
@@ -241,7 +241,7 @@ Running `compile(letExp, Map())` would yield the following Scala code:
241241
```scala
242242
'{ val y = 3; (2 + y) + 4 }
243243
```
244-
The body of the first clause, `case Num(n) => n.toExpr`, looks suspicious. `n`
244+
The body of the first clause, `case Num(n) => Expr(n)`, looks suspicious. `n`
245245
is declared as an `Int`, yet it is converted to an `Expr[Int]` with `toExpr`.
246246
Shouldn’t `n` be quoted? In fact this would not
247247
work since replacing `n` by `'n` in the clause would not be phase
@@ -308,7 +308,7 @@ Using lifting, we can now give the missing definition of `showExpr` in the intro
308308
```scala
309309
def showExpr[T](expr: Expr[T]): Expr[String] = {
310310
val code: String = expr.show
311-
code.toExpr
311+
Expr(code)
312312
}
313313
```
314314
That is, the `showExpr` method converts its `Expr` argument to a string (`code`), and lifts

docs/docs/reference/metaprogramming/tasty-reflect.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ The method `qctx.tasty.Term.seal[T]` provides a way to go back to a
6868
`quoted.Expr[Any]`. Note that the type is `Expr[Any]`. Consequently, the type
6969
must be set explicitly with a checked `cast` call. If the type does not conform
7070
to it an exception will be thrown. In the code above, we could have replaced
71-
`n.toExpr` by `xTree.seal.cast[Int]`.
71+
`Expr(n)` by `xTree.seal.cast[Int]`.
7272

7373
### Obtaining the underlying argument
7474

library/src-bootstrapped/dotty/internal/StringContextMacro.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,6 @@ object StringContextMacro {
751751
}
752752

753753
// macro expansion
754-
'{(${parts.mkString.toExpr}).format(${argsExpr}: _*)}
754+
'{(${Expr(parts.mkString)}).format(${argsExpr}: _*)}
755755
}
756756
}

library/src-bootstrapped/scala/quoted/Liftable.scala

Lines changed: 40 additions & 40 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)