Skip to content

Commit 619f66a

Browse files
Merge pull request #10830 from dotty-staging/remove-deprecated-methods-from-library
Remove library methods deprecated in M3
2 parents bfb0b81 + 951c250 commit 619f66a

File tree

30 files changed

+48
-150
lines changed

30 files changed

+48
-150
lines changed

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

Lines changed: 0 additions & 14 deletions
This file was deleted.

library/src/scala/deriving/Helpers.scala

Lines changed: 0 additions & 21 deletions
This file was deleted.

library/src/scala/quoted/Const.scala

Lines changed: 0 additions & 38 deletions
This file was deleted.

library/src/scala/quoted/Consts.scala

Lines changed: 0 additions & 30 deletions
This file was deleted.

library/src/scala/quoted/Quotes.scala

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,6 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
2828
*/
2929
def matches(that: Expr[Any]): Boolean
3030

31-
@deprecated("Use `.value` instead. This will be removed in 3.0.0-RC1", "3.0.0-M3")
32-
def unlift(using FromExpr[T]): Option[T] = self.value
33-
34-
@deprecated("Use `.valueOrError` instead. This will be removed in 3.0.0-RC1", "3.0.0-M3")
35-
def unliftOrError(using FromExpr[T]): T = self.valueOrError
36-
3731
/** Return the value of this expression.
3832
*
3933
* Returns `None` if the expression does not represent a value or possibly contains side effects.
@@ -228,9 +222,6 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
228222

229223
/** Methods of the module object `val Tree` */
230224
trait TreeModule { this: Tree.type =>
231-
/** Returns the Term representation this expression */
232-
@deprecated("Use `expr.asTerm` instead (must `import quotes.reflect._`). This will be removed in 3.0.0-RC1", "3.0.0-M3")
233-
def of(expr: Expr[Any]): Tree = expr.asTerm
234225
}
235226

236227
/** Makes extension methods on `Tree` available without any imports */
@@ -523,10 +514,6 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
523514
/** Methods of the module object `val Term` */
524515
trait TermModule { this: Term.type =>
525516

526-
/** Returns the Term representation this expression */
527-
@deprecated("Use `expr.asTerm` instead (must `import quotes.reflect._`). This will be removed in 3.0.0-RC1", "3.0.0-M3")
528-
def of(expr: Expr[Any]): Term = expr.asTerm
529-
530517
/** Returns a term that is functionally equivalent to `t`,
531518
* however if `t` is of the form `((y1, ..., yn) => e2)(e1, ..., en)`
532519
* then it optimizes this the top most call by returning the `Some`

tests/bench/string-interpolation-macro/Macro.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ object Macro {
99
var res: Expr[String] = null
1010
for _ <- 0 to 5_000 do
1111
(strCtxExpr, argsExpr) match {
12-
case ('{ StringContext(${Varargs(Consts(parts))}: _*) }, Varargs(Consts(args))) =>
12+
case ('{ StringContext(${Varargs(Exprs(parts))}: _*) }, Varargs(Exprs(args))) =>
1313
res = Expr(StringContext(parts: _*).s(args: _*))
1414
case _ => ???
1515
}

tests/neg-macros/i6432/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ object Macro {
99
import quotes.reflect._
1010
sc match {
1111
case '{ StringContext(${Varargs(parts)}: _*) } =>
12-
for (part @ Const(s) <- parts)
12+
for (part @ Expr(s) <- parts)
1313
report.error(s, part.asTerm.pos)
1414
}
1515
'{}

tests/neg-macros/i6432b/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ object Macro {
99
import quotes.reflect._
1010
sc match {
1111
case '{ StringContext(${Varargs(parts)}: _*) } =>
12-
for (part @ Const(s) <- parts)
12+
for (part @ Expr(s) <- parts)
1313
report.error(s, part.asTerm.pos)
1414
}
1515
'{}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ object E {
1010

1111
implicit def ev1[T: Type]: FromExpr[E[T]] = new FromExpr {
1212
def unapply(x: Expr[E[T]])(using Quotes) = x match {
13-
case '{ I(${Const(n)}) } => Some(I(n).asInstanceOf[E[T]])
13+
case '{ I(${Expr(n)}) } => Some(I(n).asInstanceOf[E[T]])
1414
case '{ Plus[T](${Value(x)}, ${Value(y)})(using $op) } if op.matches('{Plus2.IPlus}) => Some(Plus(x, y)(using Plus2.IPlus.asInstanceOf[Plus2[T]]).asInstanceOf[E[T]])
1515
case _ => None
1616
}

tests/neg-with-compiler/GenericNumLits/EvenFromDigitsImpl_1.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import scala.quoted._
44
import Even._
55

66
object EvenFromDigitsImpl:
7-
def apply(digits: Expr[String])(using Quotes): Expr[Even] = digits match {
8-
case Const(ds) =>
7+
def apply(digits: Expr[String])(using Quotes): Expr[Even] = digits.value match {
8+
case Some(ds) =>
99
val ev =
1010
try evenFromDigits(ds)
1111
catch {

tests/run-macros/expr-map-1/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ private def stringRewriter(e: Expr[Any])(using Quotes): Expr[Any] =
99
private object StringRewriter extends ExprMap {
1010

1111
def transform[T](e: Expr[T])(using Type[T])(using Quotes): Expr[T] = e match
12-
case Const(s: String) =>
12+
case '{ ${Expr(s)}: String } =>
1313
Expr(s.reverse) match
1414
case '{ $x: T } => x
1515
case _ => e // e had a singlton String type

tests/run-macros/flops-rewrite-2/Macro_1.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ private def rewriteMacro[T: Type](x: Expr[T])(using Quotes): Expr[T] = {
2626
case (_, Some(_)) => '{ $y * $x }
2727
case _ => '{ $x * $y }
2828
}
29-
case '{ power(${Const(x)}, ${Const(y)}) } =>
29+
case '{ power(${Expr(x)}, ${Expr(y)}) } =>
3030
Expr(power(x, y))
31-
case '{ power($x, ${Const(y)}) } =>
31+
case '{ power($x, ${Expr(y)}) } =>
3232
if y == 0 then '{1}
3333
else '{ times($x, power($x, ${Expr(y-1)})) }
3434
}),

tests/run-macros/flops-rewrite-3/Macro_1.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ private def rewriteMacro[T: Type](x: Expr[T])(using Quotes): Expr[T] = {
2525
case (_, Some(_)) => '{ $y * $x }
2626
case _ => '{ $x * $y }
2727
}
28-
case '{ power(${Const(x)}, ${Const(y)}) } =>
28+
case '{ power(${Expr(x)}, ${Expr(y)}) } =>
2929
Expr(power(x, y))
30-
case '{ power($x, ${Const(y)}) } =>
30+
case '{ power($x, ${Expr(y)}) } =>
3131
if y == 0 then '{1}
3232
else '{ times($x, power($x, ${Expr(y-1)})) }
3333
}

tests/run-macros/i6270/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ object api {
1414

1515
private def reflImplColor(x: Expr[String])(using Quotes) : Expr[String] = {
1616
import quotes.reflect._
17-
Expr(Term.of(x).show(using Printer.TreeAnsiCode))
17+
Expr(x.asTerm.show(using Printer.TreeAnsiCode))
1818
}
1919
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ object E {
1111

1212
implicit def ev1[T: Type]: FromExpr[E[T]] = new FromExpr { // TODO use type class derivation
1313
def unapply(x: Expr[E[T]])(using Quotes) = (x match {
14-
case '{ I(${Const(n)}) } => Some(I(n))
15-
case '{ D(${Const(n)}) } => Some(D(n))
14+
case '{ I(${Expr(n)}) } => Some(I(n))
15+
case '{ D(${Expr(n)}) } => Some(D(n))
1616
case '{ Plus[Int](${Value(x)}, ${Value(y)})(using $op) } => Some(Plus(x, y)(using Plus2.IPlus))
1717
case '{ Plus[Double](${Value(x)}, ${Value(y)})(using $op) } => Some(Plus(x, y)(using Plus2.DPlus))
1818
case '{ Times[Int](${Value(x)}, ${Value(y)})(using $op) } => Some(Times(x, y)(using Times2.ITimes))

tests/run-macros/quote-matcher-string-interpolator-3/quoted_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ object Macros {
88

99
private def impl(self: Expr[StringContext], args: Expr[Seq[String]])(using Quotes): Expr[String] = {
1010
self match {
11-
case '{ StringContext(${Varargs(Consts(parts))}: _*) } =>
11+
case '{ StringContext(${Varargs(Exprs(parts))}: _*) } =>
1212
val upprerParts: List[String] = parts.toList.map(_.toUpperCase)
1313
val upprerPartsExpr: Expr[List[String]] = Expr.ofList(upprerParts.map(Expr(_)))
1414
'{ StringContext($upprerPartsExpr: _*).s($args: _*) }

tests/run-macros/quote-matcher-symantics-1/quoted_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ object Macros {
1010

1111
def lift(e: Expr[DSL]): Expr[T] = e match {
1212

13-
case '{ LitDSL(${ Const(c) }) } =>
13+
case '{ LitDSL(${ Expr(c) }) } =>
1414
'{ $sym.value(${Expr(c)}) }
1515

1616
case '{ ($x: DSL) + ($y: DSL) } =>

tests/run-macros/quote-matcher-symantics-2/quoted_1.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ object Macros {
2121

2222
def lift(e: Expr[DSL])(implicit env: Map[Int, Expr[T]]): Expr[T] = e match {
2323

24-
case '{ LitDSL(${Const(c)}) } => sym.value(c)
24+
case '{ LitDSL(${Expr(c)}) } => sym.value(c)
2525

2626
case '{ ($x: DSL) + ($y: DSL) } => sym.plus(lift(x), lift(y))
2727

@@ -35,7 +35,7 @@ object Macros {
3535
lift(close(body1)(nEnvVar))(env + (i -> lift(value)))
3636
}
3737

38-
case '{ envVar(${Const(i)}) } => env(i)
38+
case '{ envVar(${Expr(i)}) } => env(i)
3939

4040
case _ =>
4141
import quotes.reflect._

tests/run-macros/quote-matcher-symantics-3/quoted_1.scala

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ object Macros {
1818
object FromEnv {
1919
def unapply[T](e: Expr[Any])(using env: Env): Option[Expr[R[T]]] =
2020
e match
21-
case '{envVar[t](${Const(id)})} =>
21+
case '{envVar[t](${Expr(id)})} =>
2222
env.get(id).asInstanceOf[Option[Expr[R[T]]]] // We can only add binds that have the same type as the refs
2323
case _ =>
2424
None
@@ -122,3 +122,20 @@ trait Symantics {
122122
object Symantics {
123123
def fix[A, B](f: (A => B) => (A => B)): A => B = throw new Exception("Must be used inside of `lift`")
124124
}
125+
126+
object Const {
127+
def unapply[T](expr: Expr[T])(using Quotes): Option[T] = {
128+
import quotes.reflect._
129+
def rec(tree: Term): Option[T] = tree match {
130+
case Literal(c) =>
131+
c match
132+
case NullConstant() | UnitConstant() | ClassOfConstant(_) => None
133+
case _ => Some(c.value.asInstanceOf[T])
134+
case Block(Nil, e) => rec(e)
135+
case Typed(e, _) => rec(e)
136+
case Inlined(_, Nil, e) => rec(e)
137+
case _ => None
138+
}
139+
rec(expr.asTerm)
140+
}
141+
}

tests/run-macros/quoted-matching-docs/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ private def sumExprShow(argsExpr: Expr[Seq[Int]]) (using Quotes): Expr[String] =
99

1010
private def sumExpr(argsExpr: Expr[Seq[Int]])(using Quotes) : Expr[Int] = {
1111
UnsafeExpr.underlyingArgument(argsExpr) match {
12-
case Varargs(Consts(args)) => // args is of type Seq[Int]
12+
case Varargs(Exprs(args)) => // args is of type Seq[Int]
1313
Expr(args.sum) // precompute result of sum
1414
case Varargs(argExprs) => // argExprs is of type Seq[Expr[Int]]
1515
val staticSum: Int = argExprs.map(_.value.getOrElse(0)).sum

tests/run-macros/tasty-extractors-constants-1.check

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@
22
4
33
abc
44
null
5-
OK

tests/run-macros/tasty-extractors-constants-1/quoted_1.scala

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,11 @@ object Macros {
1111
val buff = new StringBuilder
1212
def stagedPrintln(x: Any): Unit = buff append java.util.Objects.toString(x) append "\n"
1313

14-
Expr(3) match { case Const(n) => stagedPrintln(n) }
15-
'{4} match { case Const(n) => stagedPrintln(n) }
16-
'{"abc"} match { case Const(n) => stagedPrintln(n) }
14+
Expr(3) match { case Expr(n) => stagedPrintln(n) }
15+
'{4} match { case Expr(n) => stagedPrintln(n) }
16+
'{"abc"} match { case Expr(n) => stagedPrintln(n) }
1717
'{null} match { case '{null} => stagedPrintln(null) }
1818

19-
'{new Object} match { case Const(n) => println(n); case _ => stagedPrintln("OK") }
20-
2119
'{print(${Expr(buff.result())})}
2220
}
2321
}

0 commit comments

Comments
 (0)