Skip to content

Commit fe64a3e

Browse files
committed
Remove splice outer quotes context
This field is no longer used and can be removed. Removing it is backwards compatible with 3.0 and later releases.
1 parent b7a7227 commit fe64a3e

21 files changed

+53
-113
lines changed

compiler/src/dotty/tools/dotc/ast/Trees.scala

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ object Trees {
682682
type ThisTree[+T <: Untyped] = QuotedExpr[T]
683683
}
684684

685-
case class SplicedExpr[+T <: Untyped] private[ast] (spliced: Tree[T], tpt: Tree[T], outerQuotes: Tree[T])(implicit @constructorOnly src: SourceFile)
685+
case class SplicedExpr[+T <: Untyped] private[ast] (spliced: Tree[T], tpt: Tree[T])(implicit @constructorOnly src: SourceFile)
686686
extends TermTree[T] {
687687
type ThisTree[+T <: Untyped] = SplicedExpr[T]
688688
}
@@ -1273,9 +1273,9 @@ object Trees {
12731273
case tree: QuotedExpr if (expr eq tree.expr) && (tpt eq tree.tpt) => tree
12741274
case _ => finalize(tree, untpd.QuotedExpr(expr, tpt)(sourceFile(tree)))
12751275
}
1276-
def SplicedExpr(tree: Tree)(spliced: Tree, tpt: Tree, outerQuotes: Tree)(using Context): SplicedExpr = tree match {
1277-
case tree: SplicedExpr if (spliced eq tree.spliced) && (tpt eq tree.tpt) && (outerQuotes eq tree.outerQuotes) => tree
1278-
case _ => finalize(tree, untpd.SplicedExpr(spliced, tpt, outerQuotes)(sourceFile(tree)))
1276+
def SplicedExpr(tree: Tree)(spliced: Tree, tpt: Tree)(using Context): SplicedExpr = tree match {
1277+
case tree: SplicedExpr if (spliced eq tree.spliced) && (tpt eq tree.tpt) => tree
1278+
case _ => finalize(tree, untpd.SplicedExpr(spliced, tpt)(sourceFile(tree)))
12791279
}
12801280
def SingletonTypeTree(tree: Tree)(ref: Tree)(using Context): SingletonTypeTree = tree match {
12811281
case tree: SingletonTypeTree if (ref eq tree.ref) => tree
@@ -1382,8 +1382,8 @@ object Trees {
13821382
TypeDef(tree: Tree)(name, rhs)
13831383
def Template(tree: Template)(using Context)(constr: DefDef = tree.constr, parents: List[Tree] = tree.parents, derived: List[untpd.Tree] = tree.derived, self: ValDef = tree.self, body: LazyTreeList = tree.unforcedBody): Template =
13841384
Template(tree: Tree)(constr, parents, derived, self, body)
1385-
def SplicedExpr(tree: SplicedExpr)(spliced: Tree = tree.spliced, tpt: Tree = tree.tpt, outerQuotes: Tree = tree.outerQuotes)(using Context): SplicedExpr =
1386-
SplicedExpr(tree: Tree)(spliced, tpt, outerQuotes)
1385+
def SplicedExpr(tree: SplicedExpr)(spliced: Tree = tree.spliced, tpt: Tree = tree.tpt)(using Context): SplicedExpr =
1386+
SplicedExpr(tree: Tree)(spliced, tpt)
13871387
def Hole(tree: Hole)(isTerm: Boolean = tree.isTerm, idx: Int = tree.idx, args: List[Tree] = tree.args, content: Tree = tree.content, tpt: Tree = tree.tpt)(using Context): Hole =
13881388
Hole(tree: Tree)(isTerm, idx, args, content, tpt)
13891389

@@ -1518,8 +1518,8 @@ object Trees {
15181518
if (trees1 eq trees) tree else Thicket(trees1)
15191519
case tree @ QuotedExpr(expr, tpt) =>
15201520
cpy.QuotedExpr(tree)(transform(expr), transform(tpt))
1521-
case tree @ SplicedExpr(spliced, tpt, outerQuotes) =>
1522-
cpy.SplicedExpr(tree)(transform(spliced), transform(tpt), transform(outerQuotes))
1521+
case tree @ SplicedExpr(spliced, tpt) =>
1522+
cpy.SplicedExpr(tree)(transform(spliced), transform(tpt))
15231523
case tree @ Hole(_, _, args, content, tpt) =>
15241524
cpy.Hole(tree)(args = transform(args), content = transform(content), tpt = transform(tpt))
15251525
case _ =>
@@ -1663,8 +1663,8 @@ object Trees {
16631663
this(x, ts)
16641664
case QuotedExpr(expr, tpt) =>
16651665
this(this(x, expr), tpt)
1666-
case SplicedExpr(spliced, tpt, outerQuotes) =>
1667-
this(this(this(x, spliced), tpt), outerQuotes)
1666+
case SplicedExpr(spliced, tpt) =>
1667+
this(this(x, spliced), tpt)
16681668
case Hole(_, _, args, content, tpt) =>
16691669
this(this(this(x, args), content), tpt)
16701670
case _ =>

compiler/src/dotty/tools/dotc/ast/tpd.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,8 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
173173
def QuotedExpr(expr: Tree, tpt: Tree)(using Context): QuotedExpr =
174174
ta.assignType(untpd.QuotedExpr(expr, tpt), tpt)
175175

176-
def SplicedExpr(spliced: Tree, tpt: Tree, outerQuotes: Tree)(using Context): SplicedExpr =
177-
ta.assignType(untpd.SplicedExpr(spliced, tpt, outerQuotes), tpt)
176+
def SplicedExpr(spliced: Tree, tpt: Tree)(using Context): SplicedExpr =
177+
ta.assignType(untpd.SplicedExpr(spliced, tpt), tpt)
178178

179179
def TypeTree(tp: Type, inferred: Boolean = false)(using Context): TypeTree =
180180
(if inferred then untpd.InferredTypeTree() else untpd.TypeTree()).withType(tp)

compiler/src/dotty/tools/dotc/ast/untpd.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
402402
def JavaSeqLiteral(elems: List[Tree], elemtpt: Tree)(implicit src: SourceFile): JavaSeqLiteral = new JavaSeqLiteral(elems, elemtpt)
403403
def Inlined(call: tpd.Tree, bindings: List[MemberDef], expansion: Tree)(implicit src: SourceFile): Inlined = new Inlined(call, bindings, expansion)
404404
def QuotedExpr(expr: Tree, tpt: Tree)(implicit src: SourceFile): QuotedExpr = new QuotedExpr(expr, tpt)
405-
def SplicedExpr(spliced: Tree, tpt: Tree, outerQuotes: Tree)(implicit src: SourceFile): SplicedExpr = new SplicedExpr(spliced, tpt, outerQuotes)
405+
def SplicedExpr(spliced: Tree, tpt: Tree)(implicit src: SourceFile): SplicedExpr = new SplicedExpr(spliced, tpt)
406406
def TypeTree()(implicit src: SourceFile): TypeTree = new TypeTree()
407407
def InferredTypeTree()(implicit src: SourceFile): TypeTree = new InferredTypeTree()
408408
def SingletonTypeTree(ref: Tree)(implicit src: SourceFile): SingletonTypeTree = new SingletonTypeTree(ref)

compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -673,23 +673,14 @@ class TreePickler(pickler: TastyPickler) {
673673
.appliedTo(expr)
674674
.withSpan(tree.span)
675675
)
676-
case SplicedExpr(spliced, tpt, EmptyTree) =>
676+
case SplicedExpr(spliced, tpt) =>
677677
pickleTree(
678678
// scala.quoted.runtime.Expr.splice[<tpt>](<spliced>)
679679
ref(defn.QuotedRuntime_exprSplice)
680680
.appliedToTypeTree(tpt)
681681
.appliedTo(spliced)
682682
.withSpan(tree.span)
683683
)
684-
case SplicedExpr(spliced, tpt, quotes) =>
685-
pickleTree(
686-
// scala.quoted.runtime.Expr.nestedSplice[<tpt>](<quotes>)(<spliced>)
687-
ref(defn.QuotedRuntime_exprNestedSplice)
688-
.appliedToTypeTree(tpt)
689-
.appliedTo(quotes)
690-
.appliedTo(spliced)
691-
.withSpan(tree.span)
692-
)
693684
case Hole(_, idx, args, _, tpt) =>
694685
writeByte(HOLE)
695686
withLength {

compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,12 +1273,12 @@ class TreeUnpickler(reader: TastyReader,
12731273

12741274
def splicedExpr(fn: Tree, args: List[Tree]): Tree =
12751275
val TypeApply(_, targs) = fn: @unchecked
1276-
SplicedExpr(args.head, targs.head, EmptyTree)
1276+
SplicedExpr(args.head, targs.head)
12771277

12781278
def nestedSpliceExpr(fn: Tree, args: List[Tree]): Tree =
12791279
fn match
1280-
case Apply(TypeApply(_, targs), outerQuotes :: Nil) =>
1281-
SplicedExpr(args.head, targs.head, outerQuotes)
1280+
case Apply(TypeApply(_, targs), _ :: Nil) => // nestedSplice[T](quotes)(expr)
1281+
SplicedExpr(args.head, targs.head)
12821282
case _ => // nestedSplice[T](quotes)
12831283
tpd.Apply(fn, args)
12841284

compiler/src/dotty/tools/dotc/inlines/Inliner.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -827,14 +827,14 @@ class Inliner(val call: tpd.Tree)(using Context):
827827

828828
override def typedQuotedExpr(tree: untpd.QuotedExpr, pt: Type)(using Context): Tree =
829829
super.typedQuotedExpr(tree, pt) match
830-
case QuotedExpr(SplicedExpr(inner, _, _), _) => inner
830+
case QuotedExpr(SplicedExpr(inner, _), _) => inner
831831
case tree1 =>
832832
ctx.compilationUnit.needsStaging = true
833833
tree1
834834

835835
override def typedSplicedExpr(tree: untpd.SplicedExpr, pt: Type)(using Context): Tree =
836836
super.typedSplicedExpr(tree, pt) match
837-
case tree1 @ SplicedExpr(spliced, tpt, EmptyTree)
837+
case tree1 @ SplicedExpr(spliced, tpt)
838838
if StagingLevel.level == 0
839839
&& !hasInliningErrors =>
840840
val expanded = expandMacro(spliced, tree1.srcPos)
@@ -1078,7 +1078,7 @@ class Inliner(val call: tpd.Tree)(using Context):
10781078
level += 1
10791079
try apply(syms, body)
10801080
finally level -= 1
1081-
case SplicedExpr(body, _, _) =>
1081+
case SplicedExpr(body, _) =>
10821082
level -= 1
10831083
try apply(syms, body)
10841084
finally level += 1

compiler/src/dotty/tools/dotc/inlines/PrepareInlineable.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ object PrepareInlineable {
291291
if (inlined.is(Macro) && !ctx.isAfterTyper) {
292292

293293
def checkMacro(tree: Tree): Unit = tree match {
294-
case SplicedExpr(code, _, _) =>
294+
case SplicedExpr(code, _) =>
295295
if (code.symbol.flags.is(Inline))
296296
report.error("Macro cannot be implemented with an `inline` method", code.srcPos)
297297
Splicer.checkValidMacroBody(code)

compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -723,10 +723,9 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
723723
case QuotedExpr(expr, tpt) =>
724724
val tptText = (keywordStr("[") ~ toTextGlobal(tpt) ~ keywordStr("]")).provided(printDebug)
725725
keywordStr("'") ~ tptText ~ keywordStr("{") ~ toTextGlobal(expr) ~ keywordStr("}")
726-
case SplicedExpr(spliced, tpt, quotes) =>
726+
case SplicedExpr(spliced, tpt) =>
727727
val tptText = (keywordStr("[") ~ toTextGlobal(tpt) ~ keywordStr("]")).provided(printDebug)
728-
val quotesText = (keywordStr("(using ") ~ toTextGlobal(quotes) ~ keywordStr(")")).provided(printDebug)
729-
keywordStr("$") ~ tptText ~ keywordStr("{") ~ toTextGlobal(spliced) ~ keywordStr("}") ~ quotesText
728+
keywordStr("$") ~ tptText ~ keywordStr("{") ~ toTextGlobal(spliced) ~ keywordStr("}")
730729
case Hole(isTermHole, idx, args, content, tpt) =>
731730
val (prefix, postfix) = if isTermHole then ("{{{", "}}}") else ("[[[", "]]]")
732731
val argsText = toTextGlobal(args, ", ")

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import dotty.tools.dotc.core.Symbols._
2424
import dotty.tools.dotc.core.TypeErasure
2525
import dotty.tools.dotc.core.Types._
2626
import dotty.tools.dotc.quoted._
27-
import dotty.tools.dotc.staging.QuoteContext.*
2827
import dotty.tools.dotc.typer.ImportInfo.withRootImports
2928
import dotty.tools.dotc.util.SrcPos
3029
import dotty.tools.dotc.reporting.Message

compiler/src/dotty/tools/dotc/staging/CrossStageSafety.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import dotty.tools.dotc.core.NameKinds._
1010
import dotty.tools.dotc.core.StdNames._
1111
import dotty.tools.dotc.core.Symbols._
1212
import dotty.tools.dotc.core.Types._
13-
import dotty.tools.dotc.staging.QuoteContext.*
1413
import dotty.tools.dotc.staging.StagingLevel.*
1514
import dotty.tools.dotc.staging.QuoteTypeTags.*
1615
import dotty.tools.dotc.util.Property
@@ -151,8 +150,7 @@ class CrossStageSafety extends TreeMapWithStages {
151150
else
152151
val tp = healType(splice.srcPos)(splice.tpe.widenTermRefExpr)
153152
TypeTree(tp).withSpan(splice.tpt.span)
154-
val outerQuotes1 = splice.outerQuotes
155-
cpy.SplicedExpr(splice)(body1, tpt1, outerQuotes1)
153+
cpy.SplicedExpr(splice)(body1, tpt1)
156154
}
157155

158156
protected def transformSpliceType(body: Tree, splice: Select)(using Context): Tree = {

compiler/src/dotty/tools/dotc/staging/HealType.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import dotty.tools.dotc.core.Flags._
77
import dotty.tools.dotc.core.StdNames._
88
import dotty.tools.dotc.core.Symbols._
99
import dotty.tools.dotc.core.Types._
10-
import dotty.tools.dotc.staging.QuoteContext.*
1110
import dotty.tools.dotc.staging.StagingLevel.*
1211
import dotty.tools.dotc.staging.QuoteTypeTags.*
1312
import dotty.tools.dotc.transform.SymUtils._

compiler/src/dotty/tools/dotc/staging/QuoteContext.scala

Lines changed: 0 additions & 34 deletions
This file was deleted.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ abstract class TreeMapWithStages extends TreeMapWithImplicits {
6666
val old = inQuoteOrSplice
6767
inQuoteOrSplice = true
6868
try dropEmptyBlocks(quotedTree) match {
69-
case SplicedExpr(t, _, _) =>
69+
case SplicedExpr(t, _) =>
7070
// Optimization: `'{ $x }` --> `x`
7171
// and adapt the refinement of `Quotes { type reflect: ... } ?=> Expr[T]`
7272
transform(t).asInstance(tree.tpe)
@@ -75,7 +75,7 @@ abstract class TreeMapWithStages extends TreeMapWithImplicits {
7575
}
7676
finally inQuoteOrSplice = old
7777

78-
case tree @ SplicedExpr(splicedTree, _, _) =>
78+
case tree @ SplicedExpr(splicedTree, _) =>
7979
val old = inQuoteOrSplice
8080
inQuoteOrSplice = true
8181
try dropEmptyBlocks(splicedTree) match {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,9 @@ class ElimByName extends MiniPhase, InfoTransformer:
160160
}
161161

162162
override def transformOther(tree: Tree)(using Context): Tree = tree match
163-
case tree @ SplicedExpr(spliced, tpt, outerQuotes) =>
163+
case tree @ SplicedExpr(spliced, tpt) =>
164164
assert(dotty.tools.dotc.inlines.Inlines.inInlineMethod)
165-
cpy.SplicedExpr(tree)(transformAllDeep(spliced), tpt, outerQuotes)
165+
cpy.SplicedExpr(tree)(transformAllDeep(spliced), tpt)
166166
case tree => tree
167167

168168
object ElimByName:

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,9 @@ class FirstTransform extends MiniPhase with InfoTransformer { thisPhase =>
153153
override def transformOther(tree: Tree)(using Context): Tree = tree match {
154154
case tree: Export => EmptyTree
155155
case tree: NamedArg => transformAllDeep(tree.arg)
156-
case tree @ SplicedExpr(spliced, tpt, outerQuotes) =>
156+
case tree @ SplicedExpr(spliced, tpt) =>
157157
assert(dotty.tools.dotc.inlines.Inlines.inInlineMethod)
158-
cpy.SplicedExpr(tree)(transformAllDeep(spliced), transformAllDeep(tpt), outerQuotes)
158+
cpy.SplicedExpr(tree)(transformAllDeep(spliced), transformAllDeep(tpt))
159159
case tree => if (tree.isType) toTypeTree(tree) else tree
160160
}
161161

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import dotty.tools.dotc.quoted._
1212
import dotty.tools.dotc.inlines.Inlines
1313
import dotty.tools.dotc.ast.TreeMapWithImplicits
1414
import dotty.tools.dotc.core.DenotTransformers.IdentityDenotTransformer
15-
import dotty.tools.dotc.staging.QuoteContext.*
1615
import dotty.tools.dotc.staging.StagingLevel
1716

1817
import scala.collection.mutable.ListBuffer

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ object Splicer {
158158
case Apply(Select(QuotedExpr(expr, tpt), nme.apply), _) =>
159159
val noSpliceChecker = new TreeTraverser {
160160
def traverse(tree: Tree)(using Context): Unit = tree match
161-
case SplicedExpr(_, _, _) =>
161+
case SplicedExpr(_, _) =>
162162
report.error("Quoted argument of macros may not have splices", tree.srcPos)
163163
case _ =>
164164
traverseChildren(tree)

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import dotty.tools.dotc.core.Names._
2121
import dotty.tools.dotc.core.StdNames._
2222
import dotty.tools.dotc.quoted._
2323
import dotty.tools.dotc.config.ScalaRelease.*
24-
import dotty.tools.dotc.staging.QuoteContext.*
2524
import dotty.tools.dotc.staging.StagingLevel.*
2625
import dotty.tools.dotc.staging.QuoteTypeTags
2726

@@ -115,7 +114,7 @@ class Splicing extends MacroTransform:
115114
case tree: SplicedExpr =>
116115
if level > 1 then
117116
val spliced1 = super.transform(tree.spliced)(using spliceContext)
118-
cpy.SplicedExpr(tree)(spliced1, tree.tpt, tree.outerQuotes)
117+
cpy.SplicedExpr(tree)(spliced1, tree.tpt)
119118
else
120119
val holeIdx = numHoles
121120
numHoles += 1
@@ -235,9 +234,9 @@ class Splicing extends MacroTransform:
235234
case tree @ Assign(lhs: RefTree, rhs) =>
236235
if isCaptured(lhs.symbol) then transformSplicedAssign(tree)
237236
else super.transform(tree)
238-
case SplicedExpr(spliced, tpt, outerQuotes) =>
237+
case SplicedExpr(spliced, tpt) =>
239238
val spliced1 = transform(spliced)(using spliceContext)
240-
cpy.SplicedExpr(tree)(spliced1, tpt, outerQuotes)
239+
cpy.SplicedExpr(tree)(spliced1, tpt)
241240
case Apply(sel @ Select(app @ QuotedExpr(expr, tpt), nme.apply), quotesArgs) =>
242241
expr match
243242
case expr: RefTree if isCaptured(expr.symbol) =>
@@ -410,7 +409,7 @@ class Splicing extends MacroTransform:
410409
body(using ctx.withOwner(meth)).changeOwner(ctx.owner, meth)
411410
}
412411
})
413-
SplicedExpr(closure, TypeTree(tpe), Literal(Constant(null)))
412+
SplicedExpr(closure, TypeTree(tpe))
414413

415414
private def quoted(expr: Tree)(using Context): Tree =
416415
QuotedExpr(expr, TypeTree(expr.tpe.widenTermRefExpr))

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import dotty.tools.dotc.core.Symbols._
1010
import dotty.tools.dotc.core.Types._
1111
import dotty.tools.dotc.util.SrcPos
1212
import dotty.tools.dotc.transform.SymUtils._
13-
import dotty.tools.dotc.staging.QuoteContext.*
1413
import dotty.tools.dotc.staging.StagingLevel.*
1514
import dotty.tools.dotc.staging.CrossStageSafety
1615
import dotty.tools.dotc.staging.HealType

0 commit comments

Comments
 (0)