Skip to content

Commit 8fda2e3

Browse files
committed
Replace tasty.util.ConstantExtractor with quoted.matching.Literal
1 parent c02ce19 commit 8fda2e3

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
@@ -44,11 +44,9 @@ object Macros {
4444
}
4545

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

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

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

3+
import scala.quoted.matching._
4+
35
import scala.tasty._
46
import scala.tasty.util._
57

@@ -8,19 +10,16 @@ object Macros {
810
implicit inline def testMacro: Unit = ${impl}
911

1012
def impl(implicit reflect: Reflection): Expr[Unit] = {
11-
import reflect._
1213

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

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

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

2524
'{print(${buff.result().toExpr})}
2625
}

0 commit comments

Comments
 (0)