Skip to content

Commit ec164ff

Browse files
committed
Do not change stage of bindings
This was performed to allow some inlined `this` bindings to be evaluated. It was not always possible and hence inconsistent.
1 parent da8bbea commit ec164ff

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

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

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -521,20 +521,16 @@ class ReifyQuotes extends MacroTransformWithImplicits with InfoTransformer {
521521
stats.foreach(markDef)
522522
mapOverTree(last)
523523
case Inlined(call, bindings, InlineSplice(expansion @ Select(body, name))) =>
524-
// To maintain phase consistency, we move the binding of the this parameter into the spliced code
525-
val (splicedBindings, stagedBindings) = bindings.partition {
526-
case vdef: ValDef => vdef.symbol.is(Synthetic) // Assume that only _this bindings are tagged with Synthetic
527-
case _ => false
528-
}
529-
// Simplification of the call done in PostTyper for non-macros can also be performed now
530-
// see PostTyper `case Inlined(...) =>` for description of the simplification
531-
val call2 =
532-
if (level == 0) Ident(call.symbol.topLevelClass.typeRef).withPos(call.pos)
533-
else call
534-
val tree1 =
535-
if (level == 0) cpy.Inlined(tree)(call2, stagedBindings, Splicer.splice(body, call, splicedBindings, tree.pos).withPos(tree.pos))
536-
else seq(stagedBindings, cpy.Select(expansion)(cpy.Inlined(tree)(call, splicedBindings, body), name))
537-
val tree2 = transform(tree1)
524+
assert(call.symbol.is(Macro))
525+
val tree2 =
526+
if (level == 0) {
527+
// Simplification of the call done in PostTyper for non-macros can also be performed now
528+
// see PostTyper `case Inlined(...) =>` for description of the simplification
529+
val call2 = Ident(call.symbol.topLevelClass.typeRef).withPos(call.pos)
530+
val spliced = Splicer.splice(body, call, bindings, tree.pos).withPos(tree.pos)
531+
transform(cpy.Inlined(tree)(call2, bindings, spliced))
532+
}
533+
else super.transform(tree)
538534

539535
// due to value-discarding which converts an { e } into { e; () })
540536
if (tree.tpe =:= defn.UnitType) Block(tree2 :: Nil, Literal(Constant(())))

0 commit comments

Comments
 (0)