Skip to content

Commit e73eab7

Browse files
committed
Cleanup unnecessary staging level updates
1 parent 35408ec commit e73eab7

File tree

3 files changed

+7
-23
lines changed

3 files changed

+7
-23
lines changed

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,7 @@ object PrepareInlineable {
9191
}
9292

9393
private def stagingContext(tree: Tree)(using Context): Context = tree match
94-
case tree: Quote => StagingLevel.quoteContext
9594
case tree: Apply if tree.symbol eq defn.QuotedTypeModule_of => StagingLevel.quoteContext
96-
case tree: Splice => StagingLevel.spliceContext
9795
case _ => ctx
9896
}
9997

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,8 @@ class Inlining extends MacroTransform {
4545
new TreeTraverser {
4646
def traverse(tree: Tree)(using Context): Unit =
4747
tree match
48-
case _: Quote =>
49-
traverseChildren(tree)(using StagingLevel.quoteContext)
5048
case _: GenericApply if tree.symbol == defn.QuotedTypeModule_of =>
5149
traverseChildren(tree)(using StagingLevel.quoteContext)
52-
case _: Splice =>
53-
traverseChildren(tree)(using StagingLevel.spliceContext)
5450
case tree: RefTree if !Inlines.inInlineMethod && StagingLevel.level == 0 =>
5551
assert(!tree.symbol.isInlineMethod, tree.show)
5652
case _ =>
@@ -99,12 +95,8 @@ class Inlining extends MacroTransform {
9995
val tree1 = super.transform(tree)
10096
if tree1.tpe.isError then tree1
10197
else Inlines.inlineCall(tree1)
102-
case _: Quote =>
103-
super.transform(tree)(using StagingLevel.quoteContext)
10498
case _: GenericApply if tree.symbol == defn.QuotedTypeModule_of =>
10599
super.transform(tree)(using StagingLevel.quoteContext)
106-
case _: Splice =>
107-
super.transform(tree)(using StagingLevel.spliceContext)
108100
case _: PackageDef =>
109101
super.transform(tree) match
110102
case tree1: PackageDef =>

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

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -228,19 +228,10 @@ class Splicing extends MacroTransform:
228228
case tree @ Assign(lhs: RefTree, rhs) =>
229229
if isCaptured(lhs.symbol) then transformSplicedAssign(tree)
230230
else super.transform(tree)
231-
case Splice(expr) =>
232-
val expr1 = transform(expr)(using spliceContext)
233-
cpy.Splice(tree)(expr1)
234-
case Apply(sel @ Select(app @ Quote(expr), nme.apply), quotesArgs) =>
235-
expr match
236-
case expr: RefTree if isCaptured(expr.symbol) =>
237-
capturedTerm(expr)
238-
case _ =>
239-
val newExpr = withCurrentQuote(quotesArgs.head) {
240-
if level > 1 then transform(expr)(using quoteContext)
241-
else transformLevel0QuoteContent(expr)(using quoteContext)
242-
}
243-
cpy.Apply(tree)(cpy.Select(sel)(cpy.Quote(app)(newExpr), nme.apply), quotesArgs)
231+
case Apply(sel @ Select(app @ Quote(body), nme.apply), quotesArgs) =>
232+
body match
233+
case body: RefTree if isCaptured(body.symbol) => capturedTerm(body)
234+
case _ => withCurrentQuote(quotesArgs.head) { super.transform(tree) }
244235
case Apply(TypeApply(typeof, List(tpt)), List(quotes))
245236
if tree.symbol == defn.QuotedTypeModule_of && containsCapturedType(tpt.tpe) =>
246237
val newContent = capturedPartTypes(tpt)
@@ -253,6 +244,9 @@ class Splicing extends MacroTransform:
253244
ref(capturedType(newContent))(using ctx.withSource(tree.source)).withSpan(tree.span)
254245
case CapturedApplication(fn, argss) =>
255246
transformCapturedApplication(tree, fn, argss)
247+
case Quote(expr) if level == 0 =>
248+
val newExpr = transformLevel0QuoteContent(expr)(using quoteContext)
249+
cpy.Quote(tree)(newExpr)
256250
case _ =>
257251
super.transform(tree)
258252

0 commit comments

Comments
 (0)