Skip to content

Commit b7a7227

Browse files
committed
Add SplicedExpr to encode splices directly in the AST
1 parent deb03a7 commit b7a7227

21 files changed

+134
-75
lines changed

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,16 +1039,6 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
10391039
else None
10401040
}
10411041

1042-
/** Extractors for splices */
1043-
object SplicedExpr {
1044-
/** Extracts the content of a spliced expression tree.
1045-
* The result can be the contents of a term splice, which
1046-
* will return a term tree.
1047-
*/
1048-
def unapply(tree: tpd.Apply)(using Context): Option[tpd.Tree] =
1049-
if tree.symbol.isExprSplice then Some(tree.args.head) else None
1050-
}
1051-
10521042
/** Extractors for type splices */
10531043
object SplicedType {
10541044
/** Extracts the content of a spliced type tree.

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,11 @@ 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)
686+
extends TermTree[T] {
687+
type ThisTree[+T <: Untyped] = SplicedExpr[T]
688+
}
689+
685690
/** A type tree that represents an existing or inferred type */
686691
case class TypeTree[+T <: Untyped]()(implicit @constructorOnly src: SourceFile)
687692
extends DenotingTree[T] with TypTree[T] {
@@ -1093,6 +1098,7 @@ object Trees {
10931098
type JavaSeqLiteral = Trees.JavaSeqLiteral[T]
10941099
type Inlined = Trees.Inlined[T]
10951100
type QuotedExpr = Trees.QuotedExpr[T]
1101+
type SplicedExpr = Trees.SplicedExpr[T]
10961102
type TypeTree = Trees.TypeTree[T]
10971103
type InferredTypeTree = Trees.InferredTypeTree[T]
10981104
type SingletonTypeTree = Trees.SingletonTypeTree[T]
@@ -1267,6 +1273,10 @@ object Trees {
12671273
case tree: QuotedExpr if (expr eq tree.expr) && (tpt eq tree.tpt) => tree
12681274
case _ => finalize(tree, untpd.QuotedExpr(expr, tpt)(sourceFile(tree)))
12691275
}
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)))
1279+
}
12701280
def SingletonTypeTree(tree: Tree)(ref: Tree)(using Context): SingletonTypeTree = tree match {
12711281
case tree: SingletonTypeTree if (ref eq tree.ref) => tree
12721282
case _ => finalize(tree, untpd.SingletonTypeTree(ref)(sourceFile(tree)))
@@ -1372,6 +1382,8 @@ object Trees {
13721382
TypeDef(tree: Tree)(name, rhs)
13731383
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 =
13741384
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)
13751387
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 =
13761388
Hole(tree: Tree)(isTerm, idx, args, content, tpt)
13771389

@@ -1506,6 +1518,8 @@ object Trees {
15061518
if (trees1 eq trees) tree else Thicket(trees1)
15071519
case tree @ QuotedExpr(expr, tpt) =>
15081520
cpy.QuotedExpr(tree)(transform(expr), transform(tpt))
1521+
case tree @ SplicedExpr(spliced, tpt, outerQuotes) =>
1522+
cpy.SplicedExpr(tree)(transform(spliced), transform(tpt), transform(outerQuotes))
15091523
case tree @ Hole(_, _, args, content, tpt) =>
15101524
cpy.Hole(tree)(args = transform(args), content = transform(content), tpt = transform(tpt))
15111525
case _ =>
@@ -1649,6 +1663,8 @@ object Trees {
16491663
this(x, ts)
16501664
case QuotedExpr(expr, tpt) =>
16511665
this(this(x, expr), tpt)
1666+
case SplicedExpr(spliced, tpt, outerQuotes) =>
1667+
this(this(this(x, spliced), tpt), outerQuotes)
16521668
case Hole(_, _, args, content, tpt) =>
16531669
this(this(this(x, args), content), tpt)
16541670
case _ =>

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,9 @@ 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)
178+
176179
def TypeTree(tp: Type, inferred: Boolean = false)(using Context): TypeTree =
177180
(if inferred then untpd.InferredTypeTree() else untpd.TypeTree()).withType(tp)
178181

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +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)
405406
def TypeTree()(implicit src: SourceFile): TypeTree = new TypeTree()
406407
def InferredTypeTree()(implicit src: SourceFile): TypeTree = new InferredTypeTree()
407408
def SingletonTypeTree(ref: Tree)(implicit src: SourceFile): SingletonTypeTree = new SingletonTypeTree(ref)

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,23 @@ class TreePickler(pickler: TastyPickler) {
673673
.appliedTo(expr)
674674
.withSpan(tree.span)
675675
)
676+
case SplicedExpr(spliced, tpt, EmptyTree) =>
677+
pickleTree(
678+
// scala.quoted.runtime.Expr.splice[<tpt>](<spliced>)
679+
ref(defn.QuotedRuntime_exprSplice)
680+
.appliedToTypeTree(tpt)
681+
.appliedTo(spliced)
682+
.withSpan(tree.span)
683+
)
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+
)
676693
case Hole(_, idx, args, _, tpt) =>
677694
writeByte(HOLE)
678695
withLength {

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,6 +1271,17 @@ class TreeUnpickler(reader: TastyReader,
12711271
val TypeApply(_, targs) = fn: @unchecked
12721272
QuotedExpr(args.head, targs.head)
12731273

1274+
def splicedExpr(fn: Tree, args: List[Tree]): Tree =
1275+
val TypeApply(_, targs) = fn: @unchecked
1276+
SplicedExpr(args.head, targs.head, EmptyTree)
1277+
1278+
def nestedSpliceExpr(fn: Tree, args: List[Tree]): Tree =
1279+
fn match
1280+
case Apply(TypeApply(_, targs), outerQuotes :: Nil) =>
1281+
SplicedExpr(args.head, targs.head, outerQuotes)
1282+
case _ => // nestedSplice[T](quotes)
1283+
tpd.Apply(fn, args)
1284+
12741285
def simplifyLub(tree: Tree): Tree =
12751286
tree.overwriteType(tree.tpe.simplified)
12761287
tree
@@ -1288,6 +1299,8 @@ class TreeUnpickler(reader: TastyReader,
12881299
val args = until(end)(readTree())
12891300
if fn.symbol.isConstructor then constructorApply(fn, args)
12901301
else if fn.symbol == defn.QuotedRuntime_exprQuote then quotedExpr(fn, args)
1302+
else if fn.symbol == defn.QuotedRuntime_exprSplice then splicedExpr(fn, args)
1303+
else if fn.symbol == defn.QuotedRuntime_exprNestedSplice then nestedSpliceExpr(fn, args)
12911304
else tpd.Apply(fn, args)
12921305
case TYPEAPPLY =>
12931306
tpd.TypeApply(readTree(), until(end)(readTpt()))

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

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -815,22 +815,8 @@ class Inliner(val call: tpd.Tree)(using Context):
815815
super.typedValDef(vdef1, sym)
816816

817817
override def typedApply(tree: untpd.Apply, pt: Type)(using Context): Tree =
818-
def cancelQuotes(tree: Tree): Tree =
819-
tree match
820-
case QuotedExpr(SplicedExpr(inner), _) => inner
821-
case _ => tree
822818
val locked = ctx.typerState.ownedVars
823-
val res = cancelQuotes(constToLiteral(BetaReduce(super.typedApply(tree, pt)))) match {
824-
case res: Apply if res.symbol == defn.QuotedRuntime_exprSplice
825-
&& StagingLevel.level == 0
826-
&& !hasInliningErrors =>
827-
val expanded = expandMacro(res.args.head, tree.srcPos)
828-
transform.TreeChecker.checkMacroGeneratedTree(res, expanded)
829-
typedExpr(expanded) // Inline calls and constant fold code generated by the macro
830-
case res =>
831-
specializeEq(inlineIfNeeded(res, pt, locked))
832-
}
833-
res
819+
specializeEq(inlineIfNeeded(constToLiteral(BetaReduce(super.typedApply(tree, pt))), pt, locked))
834820

835821
override def typedTypeApply(tree: untpd.TypeApply, pt: Type)(using Context): Tree =
836822
val locked = ctx.typerState.ownedVars
@@ -840,8 +826,21 @@ class Inliner(val call: tpd.Tree)(using Context):
840826
tree1
841827

842828
override def typedQuotedExpr(tree: untpd.QuotedExpr, pt: Type)(using Context): Tree =
843-
ctx.compilationUnit.needsStaging = true
844-
super.typedQuotedExpr(tree, pt)
829+
super.typedQuotedExpr(tree, pt) match
830+
case QuotedExpr(SplicedExpr(inner, _, _), _) => inner
831+
case tree1 =>
832+
ctx.compilationUnit.needsStaging = true
833+
tree1
834+
835+
override def typedSplicedExpr(tree: untpd.SplicedExpr, pt: Type)(using Context): Tree =
836+
super.typedSplicedExpr(tree, pt) match
837+
case tree1 @ SplicedExpr(spliced, tpt, EmptyTree)
838+
if StagingLevel.level == 0
839+
&& !hasInliningErrors =>
840+
val expanded = expandMacro(spliced, tree1.srcPos)
841+
transform.TreeChecker.checkMacroGeneratedTree(tree1, expanded)
842+
typedExpr(expanded) // Inline calls and constant fold code generated by the macro
843+
case tree1 => tree1
845844

846845
override def typedMatch(tree: untpd.Match, pt: Type)(using Context): Tree =
847846
val tree1 =
@@ -1079,7 +1078,7 @@ class Inliner(val call: tpd.Tree)(using Context):
10791078
level += 1
10801079
try apply(syms, body)
10811080
finally level -= 1
1082-
case SplicedExpr(body) =>
1081+
case SplicedExpr(body, _, _) =>
10831082
level -= 1
10841083
try apply(syms, body)
10851084
finally level += 1

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ object PrepareInlineable {
9393
private def stagingContext(tree: Tree)(using Context): Context = tree match
9494
case tree: QuotedExpr => StagingLevel.quoteContext
9595
case tree: Apply if tree.symbol eq defn.QuotedTypeModule_of => StagingLevel.quoteContext
96-
case tree: Apply if tree.symbol.isExprSplice => StagingLevel.spliceContext
96+
case tree: SplicedExpr => StagingLevel.spliceContext
9797
case _ => ctx
9898
}
9999

@@ -155,7 +155,7 @@ object PrepareInlineable {
155155
val qual = qualifier(refPart)
156156
inlining.println(i"adding receiver passing inline accessor for $tree/$refPart -> (${qual.tpe}, $refPart: ${refPart.getClass}, $argss%, %")
157157

158-
// Need to dealias in order to cagtch all possible references to abstracted over types in
158+
// Need to dealias in order to catch all possible references to abstracted over types in
159159
// substitutions
160160
val dealiasMap = new TypeMap {
161161
def apply(t: Type) = mapOver(t.dealias)
@@ -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: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,8 +432,6 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
432432
changePrec (GlobalPrec) {
433433
keywordStr("throw ") ~ toText(args.head)
434434
}
435-
else if (!printDebug && fun.hasType && fun.symbol.isExprSplice)
436-
keywordStr("${") ~ toTextGlobal(args, ", ") ~ keywordStr("}")
437435
else
438436
toTextLocal(fun)
439437
~ "("
@@ -725,6 +723,10 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
725723
case QuotedExpr(expr, tpt) =>
726724
val tptText = (keywordStr("[") ~ toTextGlobal(tpt) ~ keywordStr("]")).provided(printDebug)
727725
keywordStr("'") ~ tptText ~ keywordStr("{") ~ toTextGlobal(expr) ~ keywordStr("}")
726+
case SplicedExpr(spliced, tpt, quotes) =>
727+
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
728730
case Hole(isTermHole, idx, args, content, tpt) =>
729731
val (prefix, postfix) = if isTermHole then ("{{{", "}}}") else ("[[[", "]]]")
730732
val argsText = toTextGlobal(args, ", ")

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

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -143,20 +143,16 @@ class CrossStageSafety extends TreeMapWithStages {
143143
* - If inside inlined code, expand the macro code.
144144
* - If inside of a macro definition, check the validity of the macro.
145145
*/
146-
protected def transformSplice(body: Tree, splice: Apply)(using Context): Tree = {
146+
protected def transformSplice(body: Tree, splice: SplicedExpr)(using Context): Tree = {
147147
val body1 = transform(body)(using spliceContext)
148-
splice.fun match {
149-
case fun @ TypeApply(_, _ :: Nil) =>
150-
// Type of the splice itself must also be healed
151-
// `quoted.runtime.Expr.quote[F[T]](... T ...)` --> `internal.Quoted.expr[F[$t]](... T ...)`
148+
val tpt1 =
149+
if level == 0 then
150+
transform(splice.tpt)
151+
else
152152
val tp = healType(splice.srcPos)(splice.tpe.widenTermRefExpr)
153-
cpy.Apply(splice)(cpy.TypeApply(fun)(fun.fun, tpd.TypeTree(tp) :: Nil), body1 :: Nil)
154-
case f @ Apply(fun @ TypeApply(_, _), quotes :: Nil) =>
155-
// Type of the splice itself must also be healed
156-
// `quoted.runtime.Expr.quote[F[T]](... T ...)` --> `internal.Quoted.expr[F[$t]](... T ...)`
157-
val tp = healType(splice.srcPos)(splice.tpe.widenTermRefExpr)
158-
cpy.Apply(splice)(cpy.Apply(f)(cpy.TypeApply(fun)(fun.fun, tpd.TypeTree(tp) :: Nil), quotes :: Nil), body1 :: Nil)
159-
}
153+
TypeTree(tp).withSpan(splice.tpt.span)
154+
val outerQuotes1 = splice.outerQuotes
155+
cpy.SplicedExpr(splice)(body1, tpt1, outerQuotes1)
160156
}
161157

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

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ abstract class TreeMapWithStages extends TreeMapWithImplicits {
3737
cpy.Apply(quote)(cpy.TypeApply(quote.fun)(fun, body :: Nil), quote.args)
3838

3939
/** Transform the expression splice `splice` which contains the spliced `body`. */
40-
protected def transformSplice(body: Tree, splice: Apply)(using Context): Tree
40+
protected def transformSplice(body: Tree, splice: SplicedExpr)(using Context): Tree
4141

4242
/** Transform the type splice `splice` which contains the spliced `body`. */
4343
protected def transformSpliceType(body: Tree, splice: Select)(using Context): Tree
@@ -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,14 +75,15 @@ 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 {
8282
case QuotedExpr(t, _) =>
8383
// Optimization: `${ 'x }` --> `x`
8484
transform(t)
85-
case _ => transformSplice(splicedTree, tree)
85+
case _ =>
86+
transformSplice(splicedTree, tree)
8687
}
8788
finally inQuoteOrSplice = old
8889

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,12 @@ class ElimByName extends MiniPhase, InfoTransformer:
159159
else tree
160160
}
161161

162+
override def transformOther(tree: Tree)(using Context): Tree = tree match
163+
case tree @ SplicedExpr(spliced, tpt, outerQuotes) =>
164+
assert(dotty.tools.dotc.inlines.Inlines.inInlineMethod)
165+
cpy.SplicedExpr(tree)(transformAllDeep(spliced), tpt, outerQuotes)
166+
case tree => tree
167+
162168
object ElimByName:
163169
val name: String = "elimByName"
164170
val description: String = "map by-name parameters to functions"

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +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) =>
157+
assert(dotty.tools.dotc.inlines.Inlines.inInlineMethod)
158+
cpy.SplicedExpr(tree)(transformAllDeep(spliced), transformAllDeep(tpt), outerQuotes)
156159
case tree => if (tree.isType) toTypeTree(tree) else tree
157160
}
158161

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class Inlining extends MacroTransform {
5050
traverseChildren(tree)(using StagingLevel.quoteContext)
5151
case _: GenericApply if tree.symbol == defn.QuotedTypeModule_of =>
5252
traverseChildren(tree)(using StagingLevel.quoteContext)
53-
case _: GenericApply if tree.symbol.isExprSplice =>
53+
case _: SplicedExpr =>
5454
traverseChildren(tree)(using StagingLevel.spliceContext)
5555
case tree: RefTree if !Inlines.inInlineMethod && StagingLevel.level == 0 =>
5656
assert(!tree.symbol.isInlineMethod, tree.show)
@@ -104,7 +104,7 @@ class Inlining extends MacroTransform {
104104
super.transform(tree)(using StagingLevel.quoteContext)
105105
case _: GenericApply if tree.symbol == defn.QuotedTypeModule_of =>
106106
super.transform(tree)(using StagingLevel.quoteContext)
107-
case _: GenericApply if tree.symbol.isExprSplice =>
107+
case _: SplicedExpr =>
108108
super.transform(tree)(using StagingLevel.spliceContext)
109109
case _: PackageDef =>
110110
super.transform(tree) match

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,10 @@ class PickleQuotes extends MacroTransform {
8585
tree match
8686
case tree: QuotedExpr =>
8787
assert(Inlines.inInlineMethod)
88+
case tree: SplicedExpr =>
89+
assert(Inlines.inInlineMethod)
8890
case tree: RefTree if !Inlines.inInlineMethod =>
8991
assert(tree.symbol != defn.QuotedTypeModule_of)
90-
assert(!tree.symbol.isExprSplice)
9192
case _ : TypeDef if !Inlines.inInlineMethod =>
9293
assert(!tree.symbol.hasAnnotation(defn.QuotedRuntime_SplicedTypeAnnot),
9394
s"${tree.symbol} should have been removed by PickledQuotes because it has a @quoteTypeTag")

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)

0 commit comments

Comments
 (0)