Skip to content

Commit 0cc43fb

Browse files
committed
Move Tasty macro context to Tasty module
1 parent 03e3c9b commit 0cc43fb

File tree

12 files changed

+15
-19
lines changed

12 files changed

+15
-19
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
@@ -3,3 +3,8 @@ package scala.tasty
33
import scala.tasty.reflect._
44

55
abstract class Tasty extends TastyCore with CaseDefOps with ConstantOps with ContextOps with IdOps with ImportSelectorOps with QuotedOps with PatternOps with PositionOps with Printers with SignatureOps with StandardDefinitions with TreeOps with TypeOrBoundsTreeOps with TypeOrBoundsOps
6+
7+
object Tasty {
8+
/** Compiler tasty context available in a top level ~ of a transparent macro */
9+
def macroContext: Tasty = throw new Exception("Not in transparent macro.")
10+
}

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-definitions/quoted_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import scala.tasty.util.TreeTraverser
66
object Macros {
77

88
transparent def testDefinitions(): Unit =
9-
~testDefinitionsImpl(TopLevelSplice.tastyContext) // FIXME infer TopLevelSplice.tastyContext within top level ~
9+
~testDefinitionsImpl
1010

1111
def testDefinitionsImpl(implicit tasty: Tasty): Expr[Unit] = {
1212
import tasty._

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)