Skip to content

Commit bd9b12e

Browse files
committed
Move Tasty macro context to Tasty module
1 parent d9f1d66 commit bd9b12e

File tree

11 files changed

+14
-18
lines changed

11 files changed

+14
-18
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -689,8 +689,8 @@ class Definitions {
689689
lazy val TastyTastyType = ctx.requiredClassRef("scala.tasty.Tasty")
690690
def TastyTastyClass(implicit ctx: Context) = TastyTastyType.symbol.asClass
691691

692-
lazy val TastyTopLevelSpliceModule = ctx.requiredModule("scala.tasty.TopLevelSplice")
693-
lazy val TastyTopLevelSplice_tastyContext = TastyTopLevelSpliceModule.requiredMethod("tastyContext")
692+
lazy val TastyTastyModule = ctx.requiredModule("scala.tasty.Tasty")
693+
lazy val TastyTasty_macroContext = TastyTastyModule.requiredMethod("macroContext")
694694

695695
lazy val EqType = ctx.requiredClassRef("scala.Eq")
696696
def EqClass(implicit ctx: Context) = EqType.symbol.asClass

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ class ReifyQuotes extends MacroTransformWithImplicits {
237237
def levelOK(sym: Symbol)(implicit ctx: Context): Boolean = levelOf.get(sym) match {
238238
case Some(l) =>
239239
l == level ||
240-
level == -1 && sym == defn.TastyTopLevelSplice_tastyContext
240+
level == -1 && sym == defn.TastyTasty_macroContext
241241
case None =>
242242
!sym.is(Param) || levelOK(sym.owner)
243243
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ object Splicer {
268268
case Literal(Constant(value)) =>
269269
interpretLiteral(value)
270270

271-
case _ if tree.symbol == defn.TastyTopLevelSplice_tastyContext =>
271+
case _ if tree.symbol == defn.TastyTasty_macroContext =>
272272
interpretTastyContext()
273273

274274
case StaticMethodCall(fn, args) =>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ trait Implicits { self: Typer =>
627627
}
628628

629629
def synthesizedTastyContext(formal: Type): Tree =
630-
if (ctx.inTransparentMethod || enclosingInlineds.nonEmpty) ref(defn.TastyTopLevelSplice_tastyContext)
630+
if (ctx.inTransparentMethod || enclosingInlineds.nonEmpty) ref(defn.TastyTasty_macroContext)
631631
else EmptyTree
632632

633633
/** If `formal` is of the form Eq[T, U], where no `Eq` instance exists for

library/src/scala/tasty/Tasty.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -879,3 +879,8 @@ abstract class Tasty { tasty =>
879879
}
880880

881881
}
882+
883+
object Tasty {
884+
/** Compiler tasty context available in a top level ~ of a transparent macro */
885+
def macroContext: Tasty = throw new Exception("Not in transparent macro.")
886+
}

library/src/scala/tasty/TopLevelSplice.scala

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

tests/run/tasty-custom-show/quoted_1.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import scala.quoted._
22

3-
import scala.tasty.TopLevelSplice
43
import scala.tasty.Tasty
54
import scala.tasty.util.{TreeTraverser, Show}
65

tests/run/tasty-extractors-3/quoted_1.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import scala.quoted._
22

3-
import scala.tasty.TopLevelSplice
43
import scala.tasty.Tasty
54
import scala.tasty.util.TreeTraverser
65

tests/run/tasty-getfile/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import scala.quoted._
2-
import scala.tasty.{Tasty, TopLevelSplice}
2+
import scala.tasty.Tasty
33

44
object SourceFiles {
55

tests/run/tasty-indexed-map/quoted_1.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ object Index {
2424

2525
implicit def zero[K, T]: Index[K, (K, T)] = new Index(0)
2626

27-
implicit transparent def succ[K, H, T](implicit prev: => Index[K, T]): Index[K, (H, T)] = ~succImpl(TopLevelSplice.tastyContext)('[K], '[H], '[T])
27+
implicit transparent def succ[K, H, T](implicit prev: => Index[K, T]): Index[K, (H, T)] = ~succImpl[K, H, T]
2828

29-
def succImpl[K, H, T](tasty: Tasty)(implicit k: Type[K], h: Type[H], t: Type[T]): Expr[Index[K, (H, T)]] = {
29+
def succImpl[K, H, T](implicit tasty: Tasty, k: Type[K], h: Type[H], t: Type[T]): Expr[Index[K, (H, T)]] = {
3030
import tasty._
3131

3232
def name(tp: TypeOrBounds): String = tp match {

tests/run/tasty-positioned/quoted_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ case class Positioned[T](value: T, position: Position)
1010
object Positioned {
1111

1212
implicit transparent def apply[T](x: => T): Positioned[T] =
13-
~impl('(x))('[T], TopLevelSplice.tastyContext) // FIXME infer TopLevelSplice.tastyContext within top level ~
13+
~impl('(x))
1414

1515
def impl[T](x: Expr[T])(implicit ev: Type[T], tasty: Tasty): Expr[Positioned[T]] = {
1616
import tasty.{Position => _, _}

0 commit comments

Comments
 (0)