Skip to content

Commit 8cf1385

Browse files
committed
Join containsQuotesOrSplices and containsInlineCalls
1 parent ad26554 commit 8cf1385

File tree

3 files changed

+11
-19
lines changed

3 files changed

+11
-19
lines changed

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

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,10 @@ class CompilationUnit(val source: SourceFile) {
2525
/** Pickled TASTY binaries, indexed by class. */
2626
var pickled: Map[ClassSymbol, Array[Byte]] = Map()
2727

28-
/** Will be reset to `true` if `tpdTree` contains a call to an inline method. The information
29-
* is used in phase InlineCalls in order to avoid traversing an inline-less tree.
28+
/** Will be reset to `true` if contains `Quote`, `Splice` or calls to inline methods.
29+
* The information is used in phase ReifyQuotes in order to avoid traversing a quote-less tree.
3030
*/
31-
var containsInlineCalls: Boolean = false
32-
33-
/** Will be reset to `true` if `untpdTree` contains `Quote` trees. The information
34-
* is used in phase ReifyQuotes in order to avoid traversing a quote-less tree.
35-
*/
36-
var containsQuotesOrSplices: Boolean = false
31+
var containsQuotesSplicesOrInline: Boolean = false
3732

3833
/** A structure containing a temporary map for generating inline accessors */
3934
val inlineAccessors: InlineAccessors = new InlineAccessors
@@ -53,21 +48,18 @@ object CompilationUnit {
5348
if (forceTrees) {
5449
val force = new Force
5550
force.traverse(unit1.tpdTree)
56-
unit1.containsInlineCalls = force.containsInline
57-
unit1.containsQuotesOrSplices = force.containsQuotes
51+
unit1.containsQuotesSplicesOrInline = force.containsQuotesOrInline
5852
}
5953
unit1
6054
}
6155

6256
/** Force the tree to be loaded */
6357
private class Force extends TreeTraverser {
64-
var containsInline = false
65-
var containsQuotes = false
58+
var containsQuotesOrInline = false
6659
def traverse(tree: Tree)(implicit ctx: Context): Unit = {
67-
if (tree.symbol.isQuote)
68-
containsQuotes = true
69-
if (tpd.isInlineCall(tree))
70-
containsInline = true
60+
// Note that top-level splices are still inside the inline methods
61+
if (tree.symbol.isQuote || tpd.isInlineCall(tree))
62+
containsQuotesOrInline = true
7163
traverseChildren(tree)
7264
}
7365
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,13 +173,13 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
173173

174174
if (sym.isSplice || sym.isQuote) {
175175
markAsMacro(ctx)
176-
ctx.compilationUnit.containsQuotesOrSplices = true
176+
ctx.compilationUnit.containsQuotesSplicesOrInline = true
177177
}
178178
}
179179

180180
private def handleInlineCall(sym: Symbol)(implicit ctx: Context): Unit = {
181181
if (sym.is(Inline))
182-
ctx.compilationUnit.containsInlineCalls = true
182+
ctx.compilationUnit.containsQuotesSplicesOrInline = true
183183
}
184184

185185
override def transform(tree: Tree)(implicit ctx: Context): Tree =

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class ReifyQuotes extends MacroTransformWithImplicits {
9494
}
9595

9696
override def run(implicit ctx: Context): Unit =
97-
if (ctx.compilationUnit.containsInlineCalls || ctx.compilationUnit.containsQuotesOrSplices) super.run
97+
if (ctx.compilationUnit.containsQuotesSplicesOrInline) super.run
9898

9999
protected def newTransformer(implicit ctx: Context): Transformer =
100100
new Reifier(inQuote = false, null, 0, new LevelInfo, new Embedded, ctx)

0 commit comments

Comments
 (0)