Skip to content

Commit ff100f4

Browse files
Merge pull request #8525 from dotty-staging/remove-all-quoted-deprecated-api-uses
Remove all quoted deprecated API uses
2 parents ea27651 + 6c2b280 commit ff100f4

File tree

41 files changed

+120
-121
lines changed

Some content is hidden

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

41 files changed

+120
-121
lines changed

library/src/scala/quoted/Expr.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,22 @@ class Expr[+T] private[scala] {
3434
* Emits an error error and throws if the expression does not contain a value or contains side effects.
3535
* Otherwise returns the value.
3636
*/
37-
@deprecated("Use Expr.unlifted", "0.23")
38-
final def value[U >: T](using qctx: QuoteContext, unlift: Unliftable[U]): U = unlifted
37+
@deprecated("Use Expr.unliftOrError", "0.23")
38+
final def value[U >: T](using qctx: QuoteContext, unlift: Unliftable[U]): U = unliftOrError
3939

4040
/** Return the unlifted value of this expression.
4141
*
42-
* Emits an error error and throws if the expression does not contain a value or contains side effects.
42+
* Emits an error and throws if the expression does not contain a value or contains side effects.
4343
* Otherwise returns the value.
4444
*/
45-
final def unlifted[U >: T](using qctx: QuoteContext, unlift: Unliftable[U]): U =
45+
final def unliftOrError[U >: T](using qctx: QuoteContext, unlift: Unliftable[U]): U =
4646
unlift(this).getOrElse(qctx.throwError(s"Expected a known value. \n\nThe value of: $show\ncould not be unlifted using $unlift", this))
4747

4848
/** Pattern matches `this` against `that`. Effectively performing a deep equality check.
4949
* It does the equivalent of
5050
* ```
5151
* this match
52-
* case '{...} => true // where the contens of the pattern are the contents of `that`
52+
* case '{...} => true // where the contents of the pattern are the contents of `that`
5353
* case _ => false
5454
* ```
5555
*/

library/src/scala/quoted/matching/ConstSeq.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ object ConstSeq {
1616
* }
1717
* ```
1818
*/
19-
@deprecated("use scala.quoted.Varargs(scala.quoted.Const(_)) instead", "0.23.0")
19+
@deprecated("use scala.quoted.Varargs(scala.quoted.Consts(_)) instead", "0.23.0")
2020
def unapply[T](expr: Expr[Seq[T]])(using qctx: QuoteContext): Option[Seq[T]] =
2121
import scala.quoted.Const
2222
expr match

tests/neg-macros/inline-macro-staged-interpreter/Macro_1.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ object E {
77

88
inline def eval[T](inline x: E[T]): T = ${ impl('x) }
99

10-
def impl[T: Type](x: Expr[E[T]]) (using QuoteContext): Expr[T] = x.value.lift
10+
def impl[T: Type](x: Expr[E[T]]) (using QuoteContext): Expr[T] = x.unliftOrError.lift
1111

1212
implicit def ev1[T: Type]: Unliftable[E[T]] = new Unliftable {
1313
def apply(x: Expr[E[T]]) (using QuoteContext): Option[E[T]] = x match {
@@ -18,7 +18,7 @@ object E {
1818
}
1919

2020
object Value {
21-
def unapply[T, U >: T](expr: Expr[T])(using Unliftable[U], QuoteContext): Option[U] = expr.getValue
21+
def unapply[T, U >: T](expr: Expr[T])(using Unliftable[U], QuoteContext): Option[U] = expr.unlift
2222
}
2323
}
2424

tests/neg-macros/inline-option/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import scala.quoted._
33

44
object Macro {
5-
def impl(opt: Expr[Option[Int]]) (using QuoteContext): Expr[Int] = opt.value match {
5+
def impl(opt: Expr[Option[Int]]) (using QuoteContext): Expr[Int] = opt.unliftOrError match {
66
case Some(i) => Expr(i)
77
case None => '{-1}
88
}

tests/neg-macros/inline-tuples-1/Macro_1.scala

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,26 @@ import scala.quoted._
33
import scala.quoted.autolift.{given _}
44

55
object Macros {
6-
def tup1(tup: Expr[Tuple1[Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
7-
def tup2(tup: Expr[Tuple2[Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
8-
def tup3(tup: Expr[Tuple3[Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
9-
def tup4(tup: Expr[Tuple4[Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
10-
def tup5(tup: Expr[Tuple5[Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
11-
def tup6(tup: Expr[Tuple6[Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
12-
def tup7(tup: Expr[Tuple7[Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
13-
def tup8(tup: Expr[Tuple8[Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
14-
def tup9(tup: Expr[Tuple9[Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
15-
def tup10(tup: Expr[Tuple10[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
16-
def tup11(tup: Expr[Tuple11[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
17-
def tup12(tup: Expr[Tuple12[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
18-
def tup13(tup: Expr[Tuple13[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
19-
def tup14(tup: Expr[Tuple14[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
20-
def tup15(tup: Expr[Tuple15[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
21-
def tup16(tup: Expr[Tuple16[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
22-
def tup17(tup: Expr[Tuple17[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
23-
def tup18(tup: Expr[Tuple18[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
24-
def tup19(tup: Expr[Tuple19[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
25-
def tup20(tup: Expr[Tuple20[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
26-
def tup21(tup: Expr[Tuple21[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
27-
def tup22(tup: Expr[Tuple22[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
6+
def tup1(tup: Expr[Tuple1[Int]]) (using QuoteContext): Expr[Int] = tup.unliftOrError.productIterator.map(_.asInstanceOf[Int]).sum
7+
def tup2(tup: Expr[Tuple2[Int, Int]]) (using QuoteContext): Expr[Int] = tup.unliftOrError.productIterator.map(_.asInstanceOf[Int]).sum
8+
def tup3(tup: Expr[Tuple3[Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.unliftOrError.productIterator.map(_.asInstanceOf[Int]).sum
9+
def tup4(tup: Expr[Tuple4[Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.unliftOrError.productIterator.map(_.asInstanceOf[Int]).sum
10+
def tup5(tup: Expr[Tuple5[Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.unliftOrError.productIterator.map(_.asInstanceOf[Int]).sum
11+
def tup6(tup: Expr[Tuple6[Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.unliftOrError.productIterator.map(_.asInstanceOf[Int]).sum
12+
def tup7(tup: Expr[Tuple7[Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.unliftOrError.productIterator.map(_.asInstanceOf[Int]).sum
13+
def tup8(tup: Expr[Tuple8[Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.unliftOrError.productIterator.map(_.asInstanceOf[Int]).sum
14+
def tup9(tup: Expr[Tuple9[Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.unliftOrError.productIterator.map(_.asInstanceOf[Int]).sum
15+
def tup10(tup: Expr[Tuple10[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.unliftOrError.productIterator.map(_.asInstanceOf[Int]).sum
16+
def tup11(tup: Expr[Tuple11[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.unliftOrError.productIterator.map(_.asInstanceOf[Int]).sum
17+
def tup12(tup: Expr[Tuple12[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.unliftOrError.productIterator.map(_.asInstanceOf[Int]).sum
18+
def tup13(tup: Expr[Tuple13[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.unliftOrError.productIterator.map(_.asInstanceOf[Int]).sum
19+
def tup14(tup: Expr[Tuple14[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.unliftOrError.productIterator.map(_.asInstanceOf[Int]).sum
20+
def tup15(tup: Expr[Tuple15[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.unliftOrError.productIterator.map(_.asInstanceOf[Int]).sum
21+
def tup16(tup: Expr[Tuple16[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.unliftOrError.productIterator.map(_.asInstanceOf[Int]).sum
22+
def tup17(tup: Expr[Tuple17[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.unliftOrError.productIterator.map(_.asInstanceOf[Int]).sum
23+
def tup18(tup: Expr[Tuple18[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.unliftOrError.productIterator.map(_.asInstanceOf[Int]).sum
24+
def tup19(tup: Expr[Tuple19[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.unliftOrError.productIterator.map(_.asInstanceOf[Int]).sum
25+
def tup20(tup: Expr[Tuple20[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.unliftOrError.productIterator.map(_.asInstanceOf[Int]).sum
26+
def tup21(tup: Expr[Tuple21[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.unliftOrError.productIterator.map(_.asInstanceOf[Int]).sum
27+
def tup22(tup: Expr[Tuple22[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.unliftOrError.productIterator.map(_.asInstanceOf[Int]).sum
2828
}

tests/neg-macros/quote-error-2/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import quoted._
33
object Macro_1 {
44
inline def foo(inline b: Boolean): Unit = ${ fooImpl('b) }
55
def fooImpl(b: Expr[Boolean])(using QuoteContext): Expr[Unit] =
6-
'{println(${msg(b.value)})}
6+
'{println(${msg(b.unliftOrError)})}
77

88
def msg(b: Boolean)(using qctx: QuoteContext): Expr[String] =
99
if (b) '{"foo(true)"}

tests/neg-macros/quote-error/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ import quoted._
33
object Macro_1 {
44
inline def foo(inline b: Boolean): Unit = ${fooImpl('b)}
55
def fooImpl(b: Expr[Boolean])(using qctx: QuoteContext) : Expr[Unit] =
6-
if (b.value) '{println("foo(true)")}
6+
if (b.unliftOrError) '{println("foo(true)")}
77
else { qctx.error("foo cannot be called with false"); '{ ??? } }
88
}

tests/neg-macros/quote-exception/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ import quoted._
33
object Macro_1 {
44
inline def foo(inline b: Boolean): Unit = ${fooImpl('b)}
55
def fooImpl(b: Expr[Boolean]) (using QuoteContext): Expr[Unit] =
6-
if (b.value) '{println("foo(true)")}
6+
if (b.unliftOrError) '{println("foo(true)")}
77
else ???
88
}

0 commit comments

Comments
 (0)