Skip to content

Commit da8bbea

Browse files
committed
Add comment on Inlined call simplification
Apply the simplification later in ReifyQuotes when call has been processed.
1 parent 54a1dcd commit da8bbea

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,9 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
231231
// be duplicated
232232
// 2. To enable correct pickling (calls can share symbols with the inlined code, which
233233
// would trigger an assertion when pickling).
234+
// In the case of macros we keep the call to be able to reconstruct the parameters that
235+
// are passed to the macro. This same simplification is applied in ReifiedQuotes when the
236+
// macro splices are evaluated.
234237
val callTrace =
235238
if (call.symbol.is(Macro)) call
236239
else Ident(call.symbol.topLevelClass.typeRef).withPos(call.pos)

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,9 +526,13 @@ class ReifyQuotes extends MacroTransformWithImplicits with InfoTransformer {
526526
case vdef: ValDef => vdef.symbol.is(Synthetic) // Assume that only _this bindings are tagged with Synthetic
527527
case _ => false
528528
}
529-
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
530534
val tree1 =
531-
if (level == 0) cpy.Inlined(tree)(call, stagedBindings, Splicer.splice(body, call, splicedBindings, tree.pos).withPos(tree.pos))
535+
if (level == 0) cpy.Inlined(tree)(call2, stagedBindings, Splicer.splice(body, call, splicedBindings, tree.pos).withPos(tree.pos))
532536
else seq(stagedBindings, cpy.Select(expansion)(cpy.Inlined(tree)(call, splicedBindings, body), name))
533537
val tree2 = transform(tree1)
534538

0 commit comments

Comments
 (0)