Skip to content

Commit 4f42d5f

Browse files
committed
Replace tasty.util.ConstantExtractor with quoted.matching.Literal
1 parent 35575aa commit 4f42d5f

File tree

3 files changed

+9
-42
lines changed

3 files changed

+9
-42
lines changed

library/src/scala/tasty/util/ConstantExtractor.scala

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

tests/run-with-compiler/tasty-extractors-constants-2/quoted_1.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,9 @@ object Macros {
4545
}
4646

4747
def power(n: Expr[Int], x: Expr[Double])(implicit reflect: Reflection): Expr[Double] = {
48-
import reflect._
49-
50-
val Constant = new ConstantExtractor(reflect)
48+
import quoted.matching.Literal
5149
n match {
52-
case Constant(n1) => powerCode(n1, x)
50+
case Literal(n1) => powerCode(n1, x)
5351
case _ => '{ dynamicPower($n, $x) }
5452
}
5553
}

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import scala.quoted._
22
import scala.quoted.autolift._
33

4+
import scala.quoted.matching._
5+
46
import scala.tasty._
57
import scala.tasty.util._
68

@@ -9,19 +11,16 @@ object Macros {
911
implicit inline def testMacro: Unit = ${impl}
1012

1113
def impl(implicit reflect: Reflection): Expr[Unit] = {
12-
import reflect._
1314

1415
val buff = new StringBuilder
1516
def stagedPrintln(x: Any): Unit = buff append java.util.Objects.toString(x) append "\n"
1617

17-
val Constant = new ConstantExtractor(reflect)
18-
19-
3.toExpr match { case Constant(n) => stagedPrintln(n) }
20-
'{4} match { case Constant(n) => stagedPrintln(n) }
21-
'{"abc"} match { case Constant(n) => stagedPrintln(n) }
22-
'{null} match { case Constant(n) => stagedPrintln(n) }
18+
3.toExpr match { case Literal(n) => stagedPrintln(n) }
19+
'{4} match { case Literal(n) => stagedPrintln(n) }
20+
'{"abc"} match { case Literal(n) => stagedPrintln(n) }
21+
'{null} match { case Literal(n) => stagedPrintln(n) }
2322

24-
'{new Object} match { case Constant(n) => println(n); case _ => stagedPrintln("OK") }
23+
'{new Object} match { case Literal(n) => println(n); case _ => stagedPrintln("OK") }
2524

2625
'{print(${buff.result()})}
2726
}

0 commit comments

Comments
 (0)