Skip to content

Commit 59a74e9

Browse files
committed
Put rootContext directly in Tasty
1 parent fcfc641 commit 59a74e9

File tree

22 files changed

+7
-30
lines changed

22 files changed

+7
-30
lines changed

compiler/src/dotty/tools/dotc/tastyreflect/TastyImpl.scala

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import scala.quoted
1515
import scala.reflect.ClassTag
1616
import scala.tasty.util.{Show, ShowExtractors, ShowSourceCode}
1717

18-
class TastyImpl(rootContext: Contexts.Context) extends scala.tasty.Tasty { self =>
18+
class TastyImpl(val rootContext: Contexts.Context) extends scala.tasty.Tasty { self =>
1919

2020
// ===== Quotes ===================================================
2121

@@ -43,10 +43,6 @@ class TastyImpl(rootContext: Contexts.Context) extends scala.tasty.Tasty { self
4343
def owner: Definition = FromSymbol.definition(ctx.owner)(ctx)
4444
}
4545

46-
object Context extends ContextProvider {
47-
def rootContext: Context = self.rootContext
48-
}
49-
5046
// ===== Id =======================================================
5147

5248
type Id = untpd.Ident

library/src/scala/tasty/Tasty.scala

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,7 @@ abstract class Tasty { tasty =>
3434
}
3535
implicit def ContextDeco(ctx: Context): ContextAPI
3636

37-
val Context: ContextProvider
38-
abstract class ContextProvider {
39-
implicit def rootContext: Context
40-
}
37+
implicit def rootContext: Context
4138

4239
// ===== Id =======================================================
4340

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import scala.tasty.Tasty
1818
class ConstantExtractor[T <: Tasty with Singleton](val tasty: T) {
1919
import tasty._
2020

21-
def unapply[T](expr: Expr[T])(implicit ctx: Context): Option[T] = {
21+
def unapply[T](expr: Expr[T]): Option[T] = {
2222
def const(tree: Term): Option[T] = tree match {
2323
case Term.Literal(c) => Some(c.value.asInstanceOf[T])
2424
case Term.Block(Nil, e) => const(e)

library/src/scala/tasty/util/ShowExtractors.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package scala.tasty.util
33
import scala.tasty.Tasty
44

55
class ShowExtractors[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty0) {
6-
import tasty._
6+
import tasty.{rootContext => _, _}
77

88
def showTree(tree: Tree)(implicit ctx: Context): String =
99
new Buffer().visitTree(tree).result()

library/src/scala/tasty/util/ShowSourceCode.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ package util
44
import scala.annotation.switch
55

66
class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty0) {
7-
import tasty._
7+
import tasty.{rootContext => _, _}
88

99
def showTree(tree: Tree)(implicit ctx: Context): String =
1010
(new Buffer).printTree(tree).result()

library/src/scala/tasty/util/TreeAccumulator.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package scala.tasty.util
33
import scala.tasty.Tasty
44

55
abstract class TreeAccumulator[X, T <: Tasty with Singleton](val tasty: T) {
6-
import tasty._
6+
import tasty.{rootContext => _, _}
77

88
// Ties the knot of the traversal: call `foldOver(x, tree))` to dive in the `tree` node.
99
def foldTree(x: X, tree: Tree)(implicit ctx: Context): X

library/src/scala/tasty/util/TreeTraverser.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package scala.tasty.util
33
import scala.tasty.Tasty
44

55
abstract class TreeTraverser[T <: Tasty with Singleton](tasty0: T) extends TreeAccumulator[Unit, T](tasty0) {
6-
import tasty._
6+
import tasty.{rootContext => _, _}
77

88
def traverseTree(tree: Tree)(implicit ctx: Context): Unit = traverseTreeChildren(tree)
99
def traverseTypeTree(tree: TypeOrBoundsTree)(implicit ctx: Context): Unit = traverseTypeTreeChildren(tree)

tests/neg/tasty-macro-assert/quoted_1.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ object Asserts {
1616

1717
def impl(cond: Expr[Boolean])(implicit tasty: Tasty): Expr[Unit] = {
1818
import tasty._
19-
import Context._
2019

2120
val tree = cond.toTasty
2221

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ object Macros {
1212

1313
def impl[T](x: Expr[T])(implicit tasty: Tasty): Expr[Unit] = {
1414
import tasty._
15-
import Context._
16-
1715

1816
val buff = new StringBuilder
1917

tests/run/tasty-eval/quoted_1.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ object Macros {
2121
implicit def intIsEvalable: Valuable[Int] = new Valuable[Int] {
2222
override def value(e: Expr[Int])(implicit tasty: Tasty): Option[Int] = {
2323
import tasty._
24-
import Context._
2524

2625
e.toTasty.tpe match {
2726
case Type.SymRef(ValDef(_, tpt, _), pre) =>

0 commit comments

Comments
 (0)