Skip to content

Commit 4d068d4

Browse files
authored
Merge pull request scala#8517 from dotty-staging/move-Unliftable-extractors-in-Unlifted
Move Unliftable extractors in Unlifted
2 parents 2d68072 + 594befa commit 4d068d4

File tree

6 files changed

+92
-81
lines changed

6 files changed

+92
-81
lines changed

library/src/scala/quoted/Expr.scala

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,32 @@ class Expr[+T] private[scala] {
1818
* Returns `None` if the expression does not contain a value or contains side effects.
1919
* Otherwise returns the `Some` of the value.
2020
*/
21+
@deprecated("Use Expr.unlift", "0.23")
2122
final def getValue[U >: T](using qctx: QuoteContext, unlift: Unliftable[U]): Option[U] = unlift(this)
2223

23-
/** Return the value of this expression.
24+
/** Return the unlifted value of this expression.
25+
*
26+
* Returns `None` if the expression does not contain a value or contains side effects.
27+
* Otherwise returns the `Some` of the value.
28+
*/
29+
final def unlift[U >: T](using qctx: QuoteContext, unlift: Unliftable[U]): Option[U] =
30+
unlift(this)
31+
32+
/** Return the unlifted value of this expression.
33+
*
34+
* Emits an error error and throws if the expression does not contain a value or contains side effects.
35+
* Otherwise returns the value.
36+
*/
37+
@deprecated("Use Expr.unlifted", "0.23")
38+
final def value[U >: T](using qctx: QuoteContext, unlift: Unliftable[U]): U = unlifted
39+
40+
/** Return the unlifted value of this expression.
2441
*
2542
* Emits an error error and throws if the expression does not contain a value or contains side effects.
2643
* Otherwise returns the value.
2744
*/
28-
final def value[U >: T](using qctx: QuoteContext, unlift: Unliftable[U]): U =
29-
unlift(this).getOrElse(qctx.throwError(s"Expected a known value. \n\nThe value of: $show\ncould not be recovered using $unlift", this))
45+
final def unlifted[U >: T](using qctx: QuoteContext, unlift: Unliftable[U]): U =
46+
unlift(this).getOrElse(qctx.throwError(s"Expected a known value. \n\nThe value of: $show\ncould not be unlifted using $unlift", this))
3047

3148
/** Pattern matches `this` against `that`. Effectively performing a deep equality check.
3249
* It does the equivalent of

0 commit comments

Comments
 (0)