Skip to content

Commit a1434a8

Browse files
Merge pull request #10684 from dotty-staging/depricate-old-Const-extractor
Deprecate old `Expr` value extractors
2 parents 926dbc0 + d43368e commit a1434a8

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ object FromExpr {
136136
*/
137137
given StringContextFromExpr: FromExpr[StringContext] with {
138138
def unapply(x: Expr[StringContext])(using Quotes) = x match {
139-
case '{ new StringContext(${Varargs(Consts(args))}: _*) } => Some(StringContext(args: _*))
140-
case '{ StringContext(${Varargs(Consts(args))}: _*) } => Some(StringContext(args: _*))
139+
case '{ new StringContext(${Varargs(Exprs(args))}: _*) } => Some(StringContext(args: _*))
140+
case '{ StringContext(${Varargs(Exprs(args))}: _*) } => Some(StringContext(args: _*))
141141
case _ => None
142142
}
143143
}

library/src/scala/quoted/Const.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package scala.quoted
22

33
/** Literal constant values */
4+
@deprecated("Use `scala.quoted.Expr` instead. This will be removed in 3.0.0-RC1", "3.0.0-M3")
45
object Const {
56

67
/** Matches expressions containing literal constant values and extracts the value.
@@ -18,6 +19,7 @@ object Const {
1819
*
1920
* To directly unlift an expression `expr: Expr[T]` consider using `expr.value`/`expr.valueOrError` insead.
2021
*/
22+
@deprecated("Use `scala.quoted.Expr.unapply` instead. This will be removed in 3.0.0-RC1", "3.0.0-M3")
2123
def unapply[T](expr: Expr[T])(using Quotes): Option[T] = {
2224
import quotes.reflect._
2325
def rec(tree: Term): Option[T] = tree match {

library/src/scala/quoted/Consts.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package scala.quoted
22

33
/** Literal constant values */
4+
@deprecated("Use `scala.quoted.Exprs` instead. This will be removed in 3.0.0-RC1", "3.0.0-M3")
45
object Consts {
56

67
/** Matches literal sequence of literal constant value expressions and return a sequence of values.
@@ -17,6 +18,7 @@ object Consts {
1718
*
1819
* To directly unlift all expressions in a sequence `exprs: Seq[Expr[T]]` consider using `exprs.map(_.value)`/`exprs.map(_.valueOrError)` insead.
1920
*/
21+
@deprecated("Use `scala.quoted.Exprs.unapply` instead. This will be removed in 3.0.0-RC1", "3.0.0-M3")
2022
def unapply[T](exprs: Seq[Expr[T]])(using Quotes): Option[Seq[T]] =
2123
exprs.foldRight(Option(List.empty[T])) { (elem, acc) =>
2224
(elem, acc) match {

0 commit comments

Comments
 (0)