Skip to content

Commit 37b4271

Browse files
Merge pull request #10432 from dotty-staging/shorten-name-of-quote-context
Rename QuoteContext to Quotes
2 parents 00c5f6f + 80ed86a commit 37b4271

File tree

651 files changed

+1389
-1387
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

651 files changed

+1389
-1387
lines changed

community-build/sbt-scalajs-sbt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.3.0")
1+
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.3.1")

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,7 @@ class Definitions {
797797
@tu lazy val QuotedExprClass: ClassSymbol = requiredClass("scala.quoted.Expr")
798798
@tu lazy val QuotedExprModule: Symbol = QuotedExprClass.companionModule
799799

800-
@tu lazy val QuoteContextClass: ClassSymbol = requiredClass("scala.quoted.QuoteContext")
800+
@tu lazy val QuotesClass: ClassSymbol = requiredClass("scala.quoted.Quotes")
801801

802802
@tu lazy val QuoteUnpicklerClass: ClassSymbol = requiredClass("scala.quoted.runtime.QuoteUnpickler")
803803
@tu lazy val QuoteUnpickler_unpickleExpr: Symbol = QuoteUnpicklerClass.requiredMethod("unpickleExpr")

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

+9-9
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ object StagingContext {
1717
private val QuotationLevel = new Property.Key[Int]
1818

1919
/** A key to be used in a context property that tracks the quoteation stack.
20-
* Stack containing the QuoteContext references recieved by the surrounding quotes.
20+
* Stack containing the Quotes references recieved by the surrounding quotes.
2121
*/
22-
private val QuoteContextStack = new Property.Key[List[tpd.Tree]]
22+
private val QuotesStack = new Property.Key[List[tpd.Tree]]
2323

2424
private val TaggedTypes = new Property.Key[PCPCheckAndHeal.QuoteTypeTags]
2525

@@ -31,11 +31,11 @@ object StagingContext {
3131
def quoteContext(using Context): Context =
3232
ctx.fresh.setProperty(QuotationLevel, level + 1)
3333

34-
/** Context with an incremented quotation level and pushes a refecence to a QuoteContext on the quote context stack */
35-
def pushQuoteContext(qctxRef: tpd.Tree)(using Context): Context =
36-
val old = ctx.property(QuoteContextStack).getOrElse(List.empty)
34+
/** Context with an incremented quotation level and pushes a refecence to a Quotes on the quote context stack */
35+
def pushQuotes(qctxRef: tpd.Tree)(using Context): Context =
36+
val old = ctx.property(QuotesStack).getOrElse(List.empty)
3737
ctx.fresh.setProperty(QuotationLevel, level + 1)
38-
.setProperty(QuoteContextStack, qctxRef :: old)
38+
.setProperty(QuotesStack, qctxRef :: old)
3939

4040
/** Context with a decremented quotation level. */
4141
def spliceContext(using Context): Context =
@@ -50,12 +50,12 @@ object StagingContext {
5050
/** Context with a decremented quotation level and pops the Some of top of the quote context stack or None if the stack is empty.
5151
* The quotation stack could be empty if we are in a top level splice or an eroneous splice directly witin a top level splice.
5252
*/
53-
def popQuoteContext()(using Context): (Option[tpd.Tree], Context) =
53+
def popQuotes()(using Context): (Option[tpd.Tree], Context) =
5454
val ctx1 = ctx.fresh.setProperty(QuotationLevel, level - 1)
5555
val head =
56-
ctx.property(QuoteContextStack) match
56+
ctx.property(QuotesStack) match
5757
case Some(x :: xs) =>
58-
ctx1.setProperty(QuoteContextStack, xs)
58+
ctx1.setProperty(QuotesStack, xs)
5959
Some(x)
6060
case _ =>
6161
None // Splice at level 0 or lower

compiler/src/dotty/tools/dotc/decompiler/DecompilationPrinter.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import dotty.tools.dotc.core.Phases.Phase
1111
import dotty.tools.dotc.core.tasty.TastyPrinter
1212
import dotty.tools.io.File
1313

14-
import scala.quoted.runtime.impl.QuoteContextImpl
14+
import scala.quoted.runtime.impl.QuotesImpl
1515

1616
/** Phase that prints the trees in all loaded compilation units.
1717
*
@@ -45,7 +45,7 @@ class DecompilationPrinter extends Phase {
4545
else {
4646
val unitFile = unit.source.toString.replace("\\", "/").replace(".class", ".tasty")
4747
out.println(s"/** Decompiled from $unitFile */")
48-
out.println(QuoteContextImpl.showDecompiledTree(unit.tpdTree))
48+
out.println(QuotesImpl.showDecompiledTree(unit.tpdTree))
4949
}
5050
}
5151
}

compiler/src/dotty/tools/dotc/decompiler/IDEDecompilerDriver.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import dotty.tools.dotc.core._
77
import dotty.tools.dotc.core.tasty.TastyHTMLPrinter
88
import dotty.tools.dotc.reporting._
99

10-
import scala.quoted.runtime.impl.QuoteContextImpl
10+
import scala.quoted.runtime.impl.QuotesImpl
1111

1212
/**
1313
* Decompiler to be used with IDEs
@@ -35,7 +35,7 @@ class IDEDecompilerDriver(val settings: List[String]) extends dotc.Driver {
3535
run.printSummary()
3636
val unit = ctx.run.units.head
3737

38-
val decompiled = QuoteContextImpl.showDecompiledTree(unit.tpdTree)
38+
val decompiled = QuotesImpl.showDecompiledTree(unit.tpdTree)
3939
val tree = new TastyHTMLPrinter(unit.pickled.head._2()).showContents()
4040

4141
reporter.removeBufferedMessages.foreach(message => System.err.println(message))

compiler/src/dotty/tools/dotc/quoted/PickledQuotes.scala

+10-10
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import dotty.tools.dotc.report
1919

2020
import scala.reflect.ClassTag
2121

22-
import scala.quoted.QuoteContext
22+
import scala.quoted.Quotes
2323
import scala.quoted.runtime.impl._
2424

2525
import scala.collection.mutable
@@ -41,19 +41,19 @@ object PickledQuotes {
4141
/** Transform the expression into its fully spliced Tree */
4242
def quotedExprToTree[T](expr: quoted.Expr[T])(using Context): Tree = {
4343
val expr1 = expr.asInstanceOf[ExprImpl]
44-
expr1.checkScopeId(QuoteContextImpl.scopeId)
44+
expr1.checkScopeId(QuotesImpl.scopeId)
4545
changeOwnerOfTree(expr1.tree, ctx.owner)
4646
}
4747

4848
/** Transform the expression into its fully spliced TypeTree */
4949
def quotedTypeToTree(tpe: quoted.Type[?])(using Context): Tree = {
5050
val tpe1 = tpe.asInstanceOf[TypeImpl]
51-
tpe1.checkScopeId(QuoteContextImpl.scopeId)
51+
tpe1.checkScopeId(QuotesImpl.scopeId)
5252
changeOwnerOfTree(tpe1.typeTree, ctx.owner)
5353
}
5454

5555
/** Unpickle the tree contained in the TastyExpr */
56-
def unpickleTerm(pickled: String | List[String], typeHole: (Int, Seq[Any]) => scala.quoted.Type[?], termHole: (Int, Seq[Any], scala.quoted.QuoteContext) => scala.quoted.Expr[?])(using Context): Tree = {
56+
def unpickleTerm(pickled: String | List[String], typeHole: (Int, Seq[Any]) => scala.quoted.Type[?], termHole: (Int, Seq[Any], scala.quoted.Quotes) => scala.quoted.Expr[?])(using Context): Tree = {
5757
val unpickled = withMode(Mode.ReadPositions)(unpickle(pickled, isType = false))
5858
val Inlined(call, Nil, expnasion) = unpickled
5959
val inlineCtx = inlineContext(call)
@@ -63,22 +63,22 @@ object PickledQuotes {
6363
}
6464

6565
/** Unpickle the tree contained in the TastyType */
66-
def unpickleTypeTree(pickled: String | List[String], typeHole: (Int, Seq[Any]) => scala.quoted.Type[?], termHole: (Int, Seq[Any], scala.quoted.QuoteContext) => scala.quoted.Expr[?])(using Context): Tree = {
66+
def unpickleTypeTree(pickled: String | List[String], typeHole: (Int, Seq[Any]) => scala.quoted.Type[?], termHole: (Int, Seq[Any], scala.quoted.Quotes) => scala.quoted.Expr[?])(using Context): Tree = {
6767
val unpickled = withMode(Mode.ReadPositions)(unpickle(pickled, isType = true))
6868
spliceTypes(unpickled, typeHole, termHole)
6969
}
7070

7171
/** Replace all term holes with the spliced terms */
72-
private def spliceTerms(tree: Tree, typeHole: (Int, Seq[Any]) => scala.quoted.Type[?], termHole: (Int, Seq[Any], scala.quoted.QuoteContext) => scala.quoted.Expr[?])(using Context): Tree = {
72+
private def spliceTerms(tree: Tree, typeHole: (Int, Seq[Any]) => scala.quoted.Type[?], termHole: (Int, Seq[Any], scala.quoted.Quotes) => scala.quoted.Expr[?])(using Context): Tree = {
7373
val evaluateHoles = new TreeMap {
7474
override def transform(tree: tpd.Tree)(using Context): tpd.Tree = tree match {
7575
case Hole(isTerm, idx, args) =>
7676
val reifiedArgs = args.map { arg =>
77-
if (arg.isTerm) (using qctx: QuoteContext) => new ExprImpl(arg, QuoteContextImpl.scopeId)
78-
else new TypeImpl(arg, QuoteContextImpl.scopeId)
77+
if (arg.isTerm) (using q: Quotes) => new ExprImpl(arg, QuotesImpl.scopeId)
78+
else new TypeImpl(arg, QuotesImpl.scopeId)
7979
}
8080
if isTerm then
81-
val quotedExpr = termHole(idx, reifiedArgs, QuoteContextImpl())
81+
val quotedExpr = termHole(idx, reifiedArgs, QuotesImpl())
8282
val filled = PickledQuotes.quotedExprToTree(quotedExpr)
8383

8484
// We need to make sure a hole is created with the source file of the surrounding context, even if
@@ -123,7 +123,7 @@ object PickledQuotes {
123123
}
124124

125125
/** Replace all type holes generated with the spliced types */
126-
private def spliceTypes(tree: Tree, typeHole: (Int, Seq[Any]) => scala.quoted.Type[?], termHole: (Int, Seq[Int], scala.quoted.QuoteContext) => Any)(using Context): Tree = {
126+
private def spliceTypes(tree: Tree, typeHole: (Int, Seq[Any]) => scala.quoted.Type[?], termHole: (Int, Seq[Int], scala.quoted.Quotes) => Any)(using Context): Tree = {
127127
tree match
128128
case Block(stat :: rest, expr1) if stat.symbol.hasAnnotation(defn.QuotedRuntime_SplicedTypeAnnot) =>
129129
val typeSpliceMap = (stat :: rest).iterator.map {

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ import scala.annotation.constructorOnly
5454
* typeHole = (idx: Int, args: List[Any]) => idx match {
5555
* case 0 => ...
5656
* },
57-
* termHole = (idx: Int, args: List[Any], qctx: QuoteContext) => idx match {
57+
* termHole = (idx: Int, args: List[Any], qctx: Quotes) => idx match {
5858
* case 0 => ...
5959
* ...
6060
* case <i> =>
@@ -159,7 +159,7 @@ class PickleQuotes extends MacroTransform {
159159
*/
160160
def pickleAsLiteral(lit: Literal) = {
161161
val exprType = defn.QuotedExprClass.typeRef.appliedTo(body.tpe)
162-
val lambdaTpe = MethodType(defn.QuoteContextClass.typeRef :: Nil, exprType)
162+
val lambdaTpe = MethodType(defn.QuotesClass.typeRef :: Nil, exprType)
163163
def mkConst(ts: List[Tree]) = {
164164
val reflect = ts.head.select("reflect".toTermName)
165165
val typeName = body.tpe.typeSymbol.name
@@ -239,7 +239,7 @@ class PickleQuotes extends MacroTransform {
239239
else
240240
Lambda(
241241
MethodType(
242-
List(defn.IntType, defn.SeqType.appliedTo(defn.AnyType), defn.QuoteContextClass.typeRef),
242+
List(defn.IntType, defn.SeqType.appliedTo(defn.AnyType), defn.QuotesClass.typeRef),
243243
defn.QuotedExprClass.typeRef.appliedTo(defn.AnyType)),
244244
args => {
245245
val cases = termSplices.map { case (splice, idx) =>
@@ -253,7 +253,7 @@ class PickleQuotes extends MacroTransform {
253253

254254
val quoteClass = if isType then defn.QuotedTypeClass else defn.QuotedExprClass
255255
val quotedType = quoteClass.typeRef.appliedTo(originalTp)
256-
val lambdaTpe = MethodType(defn.QuoteContextClass.typeRef :: Nil, quotedType)
256+
val lambdaTpe = MethodType(defn.QuotesClass.typeRef :: Nil, quotedType)
257257
def callUnpickle(ts: List[Tree]) = {
258258
val qctx = ts.head.asInstance(defn.QuoteUnpicklerClass.typeRef)
259259
val unpickleMeth = if isType then defn.QuoteUnpickler_unpickleType else defn.QuoteUnpickler_unpickleExpr
@@ -275,7 +275,7 @@ class PickleQuotes extends MacroTransform {
275275
def taggedType() =
276276
val typeType = defn.QuotedTypeClass.typeRef.appliedTo(body.tpe)
277277
val classTree = TypeApply(ref(defn.Predef_classOf.termRef), body :: Nil)
278-
val lambdaTpe = MethodType(defn.QuoteContextClass.typeRef :: Nil, typeType)
278+
val lambdaTpe = MethodType(defn.QuotesClass.typeRef :: Nil, typeType)
279279
def callTypeConstructorOf(ts: List[Tree]) = {
280280
val reflect = ts.head.select("reflect".toTermName)
281281
val typeRepr = reflect.select("TypeRepr".toTermName).select("typeConstructorOf".toTermName).appliedTo(classTree)
@@ -370,7 +370,7 @@ class PickleQuotes extends MacroTransform {
370370
assert(tpw.isInstanceOf[ValueType])
371371
val argTpe =
372372
if (tree.isType) defn.QuotedTypeClass.typeRef.appliedTo(tpw)
373-
else defn.FunctionType(1, isContextual = true).appliedTo(defn.QuoteContextClass.typeRef, defn.QuotedExprClass.typeRef.appliedTo(tpw))
373+
else defn.FunctionType(1, isContextual = true).appliedTo(defn.QuotesClass.typeRef, defn.QuotedExprClass.typeRef.appliedTo(tpw))
374374
val selectArg = arg.select(nme.apply).appliedTo(Literal(Constant(i))).cast(argTpe)
375375
val capturedArg = SyntheticValDef(UniqueName.fresh(tree.symbol.name.toTermName).toTermName, selectArg)
376376
i += 1

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import scala.reflect.ClassTag
2626

2727
import dotty.tools.dotc.quoted.{PickledQuotes, QuoteUtils}
2828

29-
import scala.quoted.QuoteContext
29+
import scala.quoted.Quotes
3030
import scala.quoted.runtime.impl._
3131

3232
/** Utility class to splice quoted expressions */
@@ -51,8 +51,8 @@ object Splicer {
5151
val interpreter = new Interpreter(pos, classLoader)
5252

5353
// Some parts of the macro are evaluated during the unpickling performed in quotedExprToTree
54-
val interpretedExpr = interpreter.interpret[QuoteContext => scala.quoted.Expr[Any]](tree)
55-
val interpretedTree = interpretedExpr.fold(tree)(macroClosure => PickledQuotes.quotedExprToTree(macroClosure(QuoteContextImpl())))
54+
val interpretedExpr = interpreter.interpret[Quotes => scala.quoted.Expr[Any]](tree)
55+
val interpretedTree = interpretedExpr.fold(tree)(macroClosure => PickledQuotes.quotedExprToTree(macroClosure(QuotesImpl())))
5656

5757
checkEscapedVariables(interpretedTree, macroOwner)
5858
} finally {
@@ -325,10 +325,10 @@ object Splicer {
325325
}
326326

327327
private def interpretQuote(tree: Tree)(implicit env: Env): Object =
328-
new ExprImpl(Inlined(EmptyTree, Nil, QuoteUtils.changeOwnerOfTree(tree, ctx.owner)).withSpan(tree.span), QuoteContextImpl.scopeId)
328+
new ExprImpl(Inlined(EmptyTree, Nil, QuoteUtils.changeOwnerOfTree(tree, ctx.owner)).withSpan(tree.span), QuotesImpl.scopeId)
329329

330330
private def interpretTypeQuote(tree: Tree)(implicit env: Env): Object =
331-
new TypeImpl(QuoteUtils.changeOwnerOfTree(tree, ctx.owner), QuoteContextImpl.scopeId)
331+
new TypeImpl(QuoteUtils.changeOwnerOfTree(tree, ctx.owner), QuotesImpl.scopeId)
332332

333333
private def interpretLiteral(value: Any)(implicit env: Env): Object =
334334
value.asInstanceOf[Object]

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ abstract class TreeMapWithStages(@constructorOnly ictx: Context) extends TreeMap
109109
try dropEmptyBlocks(quotedTree) match {
110110
case Spliced(t) =>
111111
// '{ $x } --> x
112-
// and adapt the refinment of `QuoteContext { type tasty: ... } ?=> Expr[T]`
112+
// and adapt the refinment of `Quotes { type tasty: ... } ?=> Expr[T]`
113113
transform(t).asInstance(tree.tpe)
114114
case _ => transformQuotation(quotedTree, tree)
115115
}

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ trait QuotesAndSplices {
4949
report.warning("Canceled splice directly inside a quote. '[ ${ XYZ } ] is equivalent to XYZ.", tree.srcPos)
5050
case _ =>
5151
}
52-
val qctx = inferImplicitArg(defn.QuoteContextClass.typeRef, tree.span)
52+
val qctx = inferImplicitArg(defn.QuotesClass.typeRef, tree.span)
5353

5454
if qctx.tpe.isInstanceOf[SearchFailureType] then
55-
report.error(missingArgMsg(qctx, defn.QuoteContextClass.typeRef, ""), ctx.source.atSpan(tree.span))
55+
report.error(missingArgMsg(qctx, defn.QuotesClass.typeRef, ""), ctx.source.atSpan(tree.span))
5656
else if !qctx.tpe.isStable then
57-
report.error(em"Quotes require stable QuoteContext, but found non stable $qctx", qctx.srcPos)
57+
report.error(em"Quotes require stable Quotes, but found non stable $qctx", qctx.srcPos)
5858

5959
val tree1 =
6060
if ctx.mode.is(Mode.Pattern) then
@@ -65,7 +65,7 @@ trait QuotesAndSplices {
6565
else report.warning(msg, tree.srcPos)
6666
typedTypeApply(untpd.TypeApply(untpd.ref(defn.QuotedTypeModule_of.termRef), tree.quoted :: Nil), pt)(using quoteContext).select(nme.apply).appliedTo(qctx)
6767
else
68-
typedApply(untpd.Apply(untpd.ref(defn.QuotedRuntime_exprQuote.termRef), tree.quoted), pt)(using pushQuoteContext(qctx)).select(nme.apply).appliedTo(qctx)
68+
typedApply(untpd.Apply(untpd.ref(defn.QuotedRuntime_exprQuote.termRef), tree.quoted), pt)(using pushQuotes(qctx)).select(nme.apply).appliedTo(qctx)
6969
tree1.withSpan(tree.span)
7070
}
7171

@@ -103,7 +103,7 @@ trait QuotesAndSplices {
103103
markAsMacro(ctx)
104104
}
105105

106-
val (outerQctx, ctx1) = popQuoteContext()
106+
val (outerQctx, ctx1) = popQuotes()
107107

108108
val internalSplice =
109109
outerQctx match

compiler/src/scala/quoted/runtime/impl/Matcher.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ import scala.annotation.{Annotation, compileTimeOnly}
9696
*/
9797
object Matcher {
9898

99-
abstract class QuoteMatcher[QCtx <: QuoteContext & Singleton](val qctx: QCtx) {
99+
abstract class QuoteMatcher[QCtx <: Quotes & Singleton](val qctx: QCtx) {
100100

101101
// TODO improve performance
102102

0 commit comments

Comments
 (0)