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) =>

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ object Macros {
1010

1111
def impl[T](x: Expr[T])(implicit tasty: Tasty): Expr[Unit] = {
1212
import tasty._
13-
import Context._
1413

1514
val tree = x.toTasty
1615
val treeStr = tree.show

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ object Macros {
1010

1111
def impl[T](x: Expr[T])(implicit tasty: Tasty): Expr[Unit] = {
1212
import tasty._
13-
import Context._
1413

1514
val tree = x.toTasty
1615

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ object Macros {
1212

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

1716
val buff = new StringBuilder
1817
val traverser = new TreeTraverser(tasty) {

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ object Macros {
1111

1212
def impl(implicit tasty: Tasty): Expr[Unit] = {
1313
import tasty._
14-
import Context._
1514

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

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ object Macros {
4646

4747
def power(n: Expr[Int], x: Expr[Double])(implicit tasty: Tasty): Expr[Double] = {
4848
import tasty._
49-
import Context._
5049

5150
val Constant = new ConstantExtractor(tasty)
5251
n match {

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ object Macros {
1111

1212
def impl[T](x: Expr[T])(implicit tasty: Tasty): Expr[Unit] = {
1313
import tasty._
14-
import Context._
1514

1615
val buff = new StringBuilder
1716

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ object Macros {
1111

1212
def impl[T](x: Type[T])(implicit tasty: Tasty): Expr[Unit] = {
1313
import tasty._
14-
import Context._
1514

1615
val tree = x.toTasty
1716
'{

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ object Index {
2828

2929
def succImpl[K, H, T](tasty: Tasty)(implicit k: Type[K], h: Type[H], t: Type[T]): Expr[Index[K, (H, T)]] = {
3030
import tasty._
31-
import Context._
3231

3332
def name(tp: TypeOrBounds): String = tp match {
3433
case Type.ConstantType(Constant.String(str)) => str

tests/run/tasty-linenumber/quoted_1.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ object LineNumber {
1515

1616
def lineImpl(x: Type[Unit])(implicit tasty: Tasty): Expr[LineNumber] = {
1717
import tasty._
18-
import Context._
1918

2019
'(new LineNumber(~x.toTasty.pos.startLine.toExpr))
2120
}

tests/run/tasty-location/quoted_1.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ object Location {
1313

1414
def impl(implicit tasty: Tasty): Expr[Location] = {
1515
import tasty._
16-
import Context._
1716

1817
def listOwnerNames(definition: Definition, acc: List[String]): List[String] = definition match {
1918
case ValDef(name, _, _) => listOwnerNames(definition.owner, name :: acc)

tests/run/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-positioned/quoted_1.scala

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

1717
def impl[T](x: Expr[T])(implicit ev: Type[T], tasty: Tasty): Expr[Positioned[T]] = {
1818
import tasty.{Position => _, _}
19-
import Context._
2019

2120
val pos = x.toTasty.pos
2221

0 commit comments

Comments
 (0)