Skip to content

Commit 99014e0

Browse files
committed
Split conditions to run Staging and PickleQuotes
1 parent 4a7e576 commit 99014e0

File tree

5 files changed

+13
-4
lines changed

5 files changed

+13
-4
lines changed

compiler/src/dotty/tools/dotc/CompilationUnit.scala

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ class CompilationUnit protected (val source: SourceFile) {
4343
*/
4444
var needsStaging: Boolean = false
4545

46+
/** Will be set to `true` if contains `Quote` that needs to be pickled
47+
* The information is used in phase `PickleQuotes` in order to avoid traversing trees that need no transformations.
48+
*/
49+
var needsQuotePickling: Boolean = false
50+
4651
/** A structure containing a temporary map for generating inline accessors */
4752
val inlineAccessors: InlineAccessors = new InlineAccessors
4853

@@ -93,7 +98,8 @@ object CompilationUnit {
9398
if (forceTrees) {
9499
val force = new Force
95100
force.traverse(unit1.tpdTree)
96-
unit1.needsStaging = force.needsStaging
101+
unit1.needsStaging = force.containsQuote
102+
unit1.needsQuotePickling = force.containsQuote
97103
}
98104
unit1
99105
}
@@ -119,10 +125,10 @@ object CompilationUnit {
119125

120126
/** Force the tree to be loaded */
121127
private class Force extends TreeTraverser {
122-
var needsStaging = false
128+
var containsQuote = false
123129
def traverse(tree: Tree)(using Context): Unit = {
124130
if (tree.symbol.isQuote)
125-
needsStaging = true
131+
containsQuote = true
126132
traverseChildren(tree)
127133
}
128134
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ class Inlining extends MacroTransform {
9292
else Inliner.inlineCall(tree1)
9393
case _: GenericApply if tree.symbol.isQuote =>
9494
ctx.compilationUnit.needsStaging = true
95+
ctx.compilationUnit.needsQuotePickling = true
9596
super.transform(tree)(using StagingContext.quoteContext)
9697
case _: GenericApply if tree.symbol.isExprSplice =>
9798
super.transform(tree)(using StagingContext.spliceContext)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class PickleQuotes extends MacroTransform {
8888
}
8989

9090
override def run(using Context): Unit =
91-
if (ctx.compilationUnit.needsStaging) super.run(using freshStagingContext)
91+
if (ctx.compilationUnit.needsQuotePickling) super.run(using freshStagingContext)
9292

9393
protected def newTransformer(using Context): Transformer = new Transformer {
9494
override def transform(tree: tpd.Tree)(using Context): tpd.Tree =

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
302302
case tree: TypeApply =>
303303
if tree.symbol.isQuote then
304304
ctx.compilationUnit.needsStaging = true
305+
ctx.compilationUnit.needsQuotePickling = true
305306
val tree1 @ TypeApply(fn, args) = normalizeTypeArgs(tree)
306307
args.foreach(checkInferredWellFormed)
307308
if (fn.symbol != defn.ChildAnnot.primaryConstructor)

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,6 +1295,7 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(using Context) {
12951295
}
12961296
if res.symbol == defn.QuotedRuntime_exprQuote then
12971297
ctx.compilationUnit.needsStaging = true
1298+
ctx.compilationUnit.needsQuotePickling = true
12981299
res
12991300

13001301
override def typedTypeApply(tree: untpd.TypeApply, pt: Type)(using Context): Tree =

0 commit comments

Comments
 (0)