Skip to content

Commit 1cd2faf

Browse files
committed
Remove Context from Printers
1 parent e8f8374 commit 1cd2faf

File tree

5 files changed

+29
-29
lines changed

5 files changed

+29
-29
lines changed

compiler/src/dotty/tools/dotc/quoted/reflect/ReflectionCompilerInterface.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class ReflectionCompilerInterface(val rootContext: Context) extends CompilerInte
5858

5959
def Constraints_context[T]: scala.quoted.QuoteContext =
6060
val ctx = rootContext.fresh.setFreshGADTBounds.addMode(Mode.GadtConstraintInference)
61-
dotty.tools.dotc.quoted.QuoteContext()(using ctx)
61+
dotty.tools.dotc.quoted.QuoteContextImpl()(using ctx)
6262

6363
def Constraints_add(syms: List[Symbol]): Boolean =
6464
rootContext.gadt.addToConstraint(syms)

library/src/scala/tasty/reflect/ExtractorsPrinter.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@ package reflect
44
class ExtractorsPrinter[R <: Reflection & Singleton](val tasty: R) extends Printer[R] {
55
import tasty._
66

7-
def showTree(tree: Tree)(using ctx: Context): String =
7+
def showTree(tree: Tree): String =
88
new Buffer().visitTree(tree).result()
99

10-
def showTypeOrBounds(tpe: TypeOrBounds)(using ctx: Context): String =
10+
def showTypeOrBounds(tpe: TypeOrBounds): String =
1111
new Buffer().visitType(tpe).result()
1212

13-
def showConstant(const: Constant)(using ctx: Context): String =
13+
def showConstant(const: Constant): String =
1414
new Buffer().visitConstant(const).result()
1515

16-
def showSymbol(symbol: Symbol)(using ctx: Context): String =
16+
def showSymbol(symbol: Symbol): String =
1717
new Buffer().visitSymbol(symbol).result()
1818

19-
def showFlags(flags: Flags)(using ctx: Context): String = {
19+
def showFlags(flags: Flags): String = {
2020
val flagList = List.newBuilder[String]
2121
if (flags.is(Flags.Abstract)) flagList += "Flags.Abstract"
2222
if (flags.is(Flags.Artifact)) flagList += "Flags.Artifact"
@@ -55,7 +55,7 @@ class ExtractorsPrinter[R <: Reflection & Singleton](val tasty: R) extends Print
5555
flagList.result().mkString(" | ")
5656
}
5757

58-
private class Buffer(using ctx: Context) { self =>
58+
private class Buffer { self =>
5959

6060
private val sb: StringBuilder = new StringBuilder
6161

library/src/scala/tasty/reflect/Printer.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ trait Printer[R <: Reflection & Singleton] {
77
val tasty: R
88

99
/** Show a String representation of a tasty.Tree */
10-
def showTree(tree: tasty.Tree)(using ctx: tasty.Context): String
10+
def showTree(tree: tasty.Tree): String
1111

1212
/** Show a String representation of a tasty.TypeOrBounds */
13-
def showTypeOrBounds(tpe: tasty.TypeOrBounds)(using ctx: tasty.Context): String
13+
def showTypeOrBounds(tpe: tasty.TypeOrBounds): String
1414

1515
/** Show a String representation of a tasty.Constant */
16-
def showConstant(const: tasty.Constant)(using ctx: tasty.Context): String
16+
def showConstant(const: tasty.Constant): String
1717

1818
/** Show a String representation of a tasty.Symbol */
19-
def showSymbol(symbol: tasty.Symbol)(using ctx: tasty.Context): String
19+
def showSymbol(symbol: tasty.Symbol): String
2020

2121
/** Show a String representation of a tasty.Flags */
22-
def showFlags(flags: tasty.Flags)(using ctx: tasty.Context): String
22+
def showFlags(flags: tasty.Flags): String
2323
}

library/src/scala/tasty/reflect/SourceCodePrinter.scala

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@ class SourceCodePrinter[R <: Reflection & Singleton](val tasty: R)(syntaxHighlig
99
import tasty._
1010
import syntaxHighlight._
1111

12-
def showTree(tree: Tree)(using ctx: Context): String =
12+
def showTree(tree: Tree): String =
1313
(new Buffer).printTree(tree).result()
1414

15-
def showTypeOrBounds(tpe: TypeOrBounds)(using ctx: Context): String =
15+
def showTypeOrBounds(tpe: TypeOrBounds): String =
1616
(new Buffer).printTypeOrBound(tpe)(using None).result()
1717

18-
def showConstant(const: Constant)(using ctx: Context): String =
18+
def showConstant(const: Constant): String =
1919
(new Buffer).printConstant(const).result()
2020

21-
def showSymbol(symbol: Symbol)(using ctx: Context): String =
21+
def showSymbol(symbol: Symbol): String =
2222
symbol.fullName
2323

24-
def showFlags(flags: Flags)(using ctx: Context): String = {
24+
def showFlags(flags: Flags): String = {
2525
val flagList = List.newBuilder[String]
2626
if (flags.is(Flags.Abstract)) flagList += "abstract"
2727
if (flags.is(Flags.Artifact)) flagList += "artifact"
@@ -60,7 +60,7 @@ class SourceCodePrinter[R <: Reflection & Singleton](val tasty: R)(syntaxHighlig
6060
flagList.result().mkString("/*", " ", "*/")
6161
}
6262

63-
private class Buffer(using ctx: Context) {
63+
private class Buffer {
6464

6565
private[this] val sb: StringBuilder = new StringBuilder
6666

@@ -1416,7 +1416,7 @@ class SourceCodePrinter[R <: Reflection & Singleton](val tasty: R)(syntaxHighlig
14161416
private[this] val names = collection.mutable.Map.empty[Symbol, String]
14171417
private[this] val namesIndex = collection.mutable.Map.empty[String, Int]
14181418

1419-
private def splicedName(sym: Symbol)(using ctx: Context): Option[String] = {
1419+
private def splicedName(sym: Symbol): Option[String] = {
14201420
sym.annots.find(_.symbol.owner == Symbol.requiredClass("scala.internal.quoted.showName")).flatMap {
14211421
case Apply(_, Literal(Constant(c: String)) :: Nil) => Some(c)
14221422
case Apply(_, Inlined(_, _, Literal(Constant(c: String))) :: Nil) => Some(c)
@@ -1437,7 +1437,7 @@ class SourceCodePrinter[R <: Reflection & Singleton](val tasty: R)(syntaxHighlig
14371437
}
14381438

14391439
private object SpecialOp {
1440-
def unapply(arg: Tree)(using ctx: Context): Option[(String, List[Term])] = arg match {
1440+
def unapply(arg: Tree): Option[(String, List[Term])] = arg match {
14411441
case arg @ Apply(fn, args) =>
14421442
fn.tpe match {
14431443
case tpe @ TermRef(ThisType(TypeRef(_, name)), name2) if name == "<special-ops>" =>
@@ -1449,7 +1449,7 @@ class SourceCodePrinter[R <: Reflection & Singleton](val tasty: R)(syntaxHighlig
14491449
}
14501450

14511451
private object Annotation {
1452-
def unapply(arg: Tree)(using ctx: Context): Option[(TypeTree, List[Term])] = arg match {
1452+
def unapply(arg: Tree): Option[(TypeTree, List[Term])] = arg match {
14531453
case New(annot) => Some((annot, Nil))
14541454
case Apply(Select(New(annot), "<init>"), args) => Some((annot, args))
14551455
case Apply(TypeApply(Select(New(annot), "<init>"), targs), args) => Some((annot, args))
@@ -1461,7 +1461,7 @@ class SourceCodePrinter[R <: Reflection & Singleton](val tasty: R)(syntaxHighlig
14611461
private object Types {
14621462

14631463
object Sequence {
1464-
def unapply(tpe: Type)(using ctx: Context): Option[Type] = tpe match {
1464+
def unapply(tpe: Type): Option[Type] = tpe match {
14651465
case AppliedType(seq, (tp: Type) :: Nil)
14661466
if seq.typeSymbol == Symbol.requiredClass("scala.collection.Seq") || seq.typeSymbol == Symbol.requiredClass("scala.collection.immutable.Seq") =>
14671467
Some(tp)
@@ -1470,7 +1470,7 @@ class SourceCodePrinter[R <: Reflection & Singleton](val tasty: R)(syntaxHighlig
14701470
}
14711471

14721472
object Repeated {
1473-
def unapply(tpe: Type)(using ctx: Context): Option[Type] = tpe match {
1473+
def unapply(tpe: Type): Option[Type] = tpe match {
14741474
case AppliedType(rep, (tp: Type) :: Nil) if rep.typeSymbol == Symbol.requiredClass("scala.<repeated>") => Some(tp)
14751475
case _ => None
14761476
}
@@ -1479,7 +1479,7 @@ class SourceCodePrinter[R <: Reflection & Singleton](val tasty: R)(syntaxHighlig
14791479
}
14801480

14811481
object PackageObject {
1482-
def unapply(tree: Tree)(using ctx: Context): Option[Tree] = tree match {
1482+
def unapply(tree: Tree): Option[Tree] = tree match {
14831483
case PackageClause(_, ValDef("package", _, _) :: body :: Nil) => Some(body)
14841484
case _ => None
14851485
}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ object Macros {
4141
new scala.tasty.reflect.Printer {
4242
val tasty = qctx.tasty
4343
import qctx.tasty._
44-
def showTree(tree: Tree)(implicit ctx: Context): String = "Tree"
45-
def showTypeOrBounds(tpe: TypeOrBounds)(implicit ctx: Context): String = "TypeOrBounds"
46-
def showConstant(const: Constant)(implicit ctx: Context): String = "Constant"
47-
def showSymbol(symbol: Symbol)(implicit ctx: Context): String = "Symbol"
48-
def showFlags(flags: Flags)(implicit ctx: Context): String = "Flags"
44+
def showTree(tree: Tree): String = "Tree"
45+
def showTypeOrBounds(tpe: TypeOrBounds): String = "TypeOrBounds"
46+
def showConstant(const: Constant): String = "Constant"
47+
def showSymbol(symbol: Symbol): String = "Symbol"
48+
def showFlags(flags: Flags): String = "Flags"
4949
}
5050
}
5151

0 commit comments

Comments
 (0)