Skip to content

Commit 786dfd9

Browse files
Merge pull request #6823 from dotty-staging/remove-implicit-tasty-Reflection-synthesis
Remove implicit `tasty.Reflection` synthesis
2 parents bbc0df7 + cc2c34b commit 786dfd9

File tree

12 files changed

+9
-47
lines changed

12 files changed

+9
-47
lines changed

compiler/src/dotty/tools/dotc/core/Definitions.scala

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -805,9 +805,6 @@ class Definitions {
805805
@threadUnsafe lazy val TastyReflectionType: TypeRef = ctx.requiredClassRef("scala.tasty.Reflection")
806806
def TastyReflectionClass(implicit ctx: Context): ClassSymbol = TastyReflectionType.symbol.asClass
807807

808-
@threadUnsafe lazy val TastyReflectionModule: TermSymbol = ctx.requiredModule("scala.tasty.Reflection")
809-
@threadUnsafe lazy val TastyReflection_macroContext: TermSymbol = TastyReflectionModule.requiredMethod("macroContext")
810-
811808
@threadUnsafe lazy val EqlType: TypeRef = ctx.requiredClassRef("scala.Eql")
812809
def EqlClass(implicit ctx: Context): ClassSymbol = EqlType.symbol.asClass
813810
def EqlModule(implicit ctx: Context): Symbol = EqlClass.companionModule

compiler/src/dotty/tools/dotc/transform/PCPCheckAndHeal.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ class PCPCheckAndHeal(@constructorOnly ictx: Context) extends TreeMapWithStages(
153153
case Some(l) =>
154154
l == level ||
155155
level == -1 && (
156-
sym == defn.TastyReflection_macroContext ||
157156
sym == defn.QuoteContext_macroContext ||
158157
// here we assume that Splicer.canBeSpliced was true before going to level -1,
159158
// this implies that all non-inline arguments are quoted and that the following two cases are checked

compiler/src/dotty/tools/dotc/transform/Splicer.scala

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ object Splicer {
105105
protected def interpretVarargs(args: List[Object])(implicit env: Env): Object =
106106
args.toSeq
107107

108-
protected def interpretTastyContext()(implicit env: Env): Object = ReflectionImpl(ctx, pos)
109108
protected def interpretQuoteContext()(implicit env: Env): Object =
110109
new scala.quoted.QuoteContext(ReflectionImpl(ctx, pos))
111110

@@ -278,7 +277,6 @@ object Splicer {
278277
protected def interpretTypeQuote(tree: tpd.Tree)(implicit env: Env): Unit = ()
279278
protected def interpretLiteral(value: Any)(implicit env: Env): Unit = ()
280279
protected def interpretVarargs(args: List[Unit])(implicit env: Env): Unit = ()
281-
protected def interpretTastyContext()(implicit env: Env): Unit = ()
282280
protected def interpretQuoteContext()(implicit env: Env): Unit = ()
283281
protected def interpretStaticMethodCall(module: Symbol, fn: Symbol, args: => List[Unit])(implicit env: Env): Unit = args.foreach(identity)
284282
protected def interpretModuleAccess(fn: Symbol)(implicit env: Env): Unit = ()
@@ -314,7 +312,6 @@ object Splicer {
314312
protected def interpretTypeQuote(tree: Tree)(implicit env: Env): Result
315313
protected def interpretLiteral(value: Any)(implicit env: Env): Result
316314
protected def interpretVarargs(args: List[Result])(implicit env: Env): Result
317-
protected def interpretTastyContext()(implicit env: Env): Result
318315
protected def interpretQuoteContext()(implicit env: Env): Result
319316
protected def interpretStaticMethodCall(module: Symbol, fn: Symbol, args: => List[Result])(implicit env: Env): Result
320317
protected def interpretModuleAccess(fn: Symbol)(implicit env: Env): Result
@@ -338,9 +335,6 @@ object Splicer {
338335
case Literal(Constant(value)) =>
339336
interpretLiteral(value)
340337

341-
case _ if tree.symbol == defn.TastyReflection_macroContext =>
342-
interpretTastyContext()
343-
344338
case _ if tree.symbol == defn.QuoteContext_macroContext =>
345339
interpretQuoteContext()
346340

compiler/src/dotty/tools/dotc/typer/Implicits.scala

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -702,11 +702,6 @@ trait Implicits { self: Typer =>
702702
}
703703
}
704704

705-
lazy val synthesizedTastyContext: SpecialHandler =
706-
(formal, span) => implicit ctx =>
707-
if (ctx.inInlineMethod || enclosingInlineds.nonEmpty) ref(defn.TastyReflection_macroContext)
708-
else EmptyTree
709-
710705
lazy val synthesizedQuoteContext: SpecialHandler =
711706
(formal, span) => implicit ctx =>
712707
if (ctx.inInlineMethod || enclosingInlineds.nonEmpty) ref(defn.QuoteContext_macroContext)
@@ -1039,7 +1034,6 @@ trait Implicits { self: Typer =>
10391034
defn.ClassTagClass -> synthesizedClassTag,
10401035
defn.QuotedTypeClass -> synthesizedTypeTag,
10411036
defn.QuoteContextClass -> synthesizedQuoteContext,
1042-
defn.TastyReflectionClass -> synthesizedTastyContext,
10431037
defn.EqlClass -> synthesizedEq,
10441038
defn.TupledFunctionClass -> synthesizedTupleFunction,
10451039
defn.ValueOfClass -> synthesizedValueOf,

library/src/scala/tasty/Reflection.scala

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,3 @@ class Reflection(val kernel: Kernel)
4646
}
4747

4848
}
49-
50-
object Reflection {
51-
/** Compiler tasty context available in a top level ~ of an inline macro */
52-
@deprecated("Use scala.quoted.QuoteContext instead", "0.17")
53-
def macroContext: Reflection = throw new Exception("Not in inline macro.")
54-
}

tests/run-macros/quote-matching-optimize-1/Macro_1.scala

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
import scala.quoted._
22
import scala.quoted.autolift._
33

4-
import scala.tasty.Reflection
5-
64
object Macro {
75

86
inline def optimize[T](x: => T): Any = ${ Macro.impl('x) }
97

10-
def impl[T: Type](x: Expr[T]) given Reflection: Expr[Any] = {
11-
val reflect = the[Reflection]
12-
import reflect._ // TODO remove
8+
def impl[T: Type](x: Expr[T]) given QuoteContext: Expr[Any] = {
139

1410
def optimize(x: Expr[Any]): Expr[Any] = x match {
1511
case '{ type $t; ($ls: List[`$t`]).filter($f).filter($g) } =>

tests/run-macros/quote-matching-optimize-2/Macro_1.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ object Macro {
77

88
inline def optimize[T](x: => T): Any = ${ Macro.impl('x) }
99

10-
def impl[T: Type](x: Expr[T]) given Reflection: Expr[Any] = {
11-
val reflect = the[Reflection]
12-
import reflect._ // TODO remove
10+
def impl[T: Type](x: Expr[T]) given QuoteContext: Expr[Any] = {
1311

1412
def optimize(x: Expr[Any]): Expr[Any] = x match {
1513
case '{ ($ls: List[$t]).filter($f).filter($g) } =>

tests/run-macros/quote-matching-optimize-3/Macro_1.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ object Macro {
77

88
inline def optimize[T](x: => T): Any = ${ Macro.impl('x) }
99

10-
def impl[T: Type](x: Expr[T]) given Reflection: Expr[Any] = {
11-
val reflect = the[Reflection]
12-
import reflect._ // TODO remove
10+
def impl[T: Type](x: Expr[T]) given QuoteContext: Expr[Any] = {
1311

1412
def optimize(x: Expr[Any]): Expr[Any] = x match {
1513
case '{ ($ls: List[$t]).filter($f).filter($g) } =>

tests/run-macros/quoted-pattern-type/Macro_1.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import scala.quoted._
2-
import scala.tasty.Reflection
32

43
object Lib {
54

65
inline def foo[T](arg: => T): T = ${ impl('arg) }
76

8-
private def impl[T: Type](arg: Expr[T])(implicit refl: Reflection): Expr[T] = {
7+
private def impl[T: Type](arg: Expr[T]) given QuoteContext: Expr[T] = {
98
arg match {
109
case e @ '{ $x: Boolean } => '{ println("Boolean: " + $e); $e }
1110
case e @ '{ $x: Int } => '{ println("Int: " + $x); $x }

tests/run-macros/reflect-lambda/assert_1.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import scala.quoted._
2-
import scala.tasty._
32

43
object lib {
54

65
inline def assert(condition: => Boolean): Unit = ${ assertImpl('condition, '{""}) }
76

8-
def assertImpl(cond: Expr[Boolean], clue: Expr[Any])(implicit refl: Reflection): Expr[Unit] = {
9-
import refl._
7+
def assertImpl(cond: Expr[Boolean], clue: Expr[Any]) given (qctx: QuoteContext): Expr[Unit] = {
8+
import qctx.tasty._
109
import util._
1110

1211
cond.unseal.underlyingArgument match {

tests/run-with-compiler/quote-matcher-type-bind/Macro_1.scala

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
11
import scala.quoted._
22
import scala.quoted.matching._
33

4-
import scala.tasty.Reflection
5-
6-
import scala.internal.quoted.Matcher._
7-
import scala.internal.Quoted._
8-
94
object Macros {
105

116
inline def swapFandG(x: => Unit): Unit = ${impl('x)}
127

13-
private def impl(x: Expr[Unit])(implicit reflect: Reflection): Expr[Unit] = {
8+
private def impl(x: Expr[Unit]) given QuoteContext: Expr[Unit] = {
149
x match {
1510
case '{ DSL.f[$t]($x) } => '{ DSL.g[$t]($x) }
1611
case '{ DSL.g[$t]($x) } => '{ DSL.f[$t]($x) }
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import scala.quoted._
2-
import scala.tasty._
32

43
object api {
54
inline def (x: => T) reflect[T] : String =
65
${ reflImpl('x) }
76

8-
private def reflImpl[T](x: Expr[T])(implicit refl: Reflection): Expr[String] = {
9-
import refl._
7+
private def reflImpl[T](x: Expr[T])(implicit qctx: QuoteContext): Expr[String] = {
8+
import qctx.tasty._
109
x.unseal.pos.sourceCode.toExpr
1110
}
1211
}

0 commit comments

Comments
 (0)