Skip to content

Commit e1b34c7

Browse files
committed
Make reposition Inlined agnostic
1 parent cf995b5 commit e1b34c7

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,15 @@ object Inliner {
152152

153153
/** Replace `Inlined` node by a block that contains its bindings and expansion */
154154
def dropInlined(inlined: Inlined)(implicit ctx: Context): Tree =
155-
if (enclosingInlineds.nonEmpty) inlined // Remove in the outer most inlined call
156-
else reposition(inlined, inlined.call.span)
155+
val tree1 =
156+
if inlined.bindings.isEmpty then inlined.expansion
157+
else cpy.Block(inlined)(inlined.bindings, inlined.expansion)
158+
// Reposition in the outer most inlined call
159+
if (enclosingInlineds.nonEmpty) tree1 else reposition(tree1, inlined.span)
157160

158161
def reposition(tree: Tree, callSpan: Span)(implicit ctx: Context): Tree = {
162+
// Reference test tests/run/i4947b
163+
159164
val curSource = ctx.compilationUnit.source
160165

161166
// Tree copier that changes the source of all trees to `curSource`
@@ -183,9 +188,6 @@ object Inliner {
183188
given as Context = ctx.withSource(curSource)
184189

185190
tree match {
186-
case tree: Inlined =>
187-
if tree.bindings.isEmpty then transform(tree.expansion)
188-
else transform(cpy.Block(tree)(tree.bindings, tree.expansion))
189191
case tree: Ident => finalize(untpd.Ident(tree.name)(curSource))
190192
case tree: Literal => finalize(untpd.Literal(tree.const)(curSource))
191193
case tree: This => finalize(untpd.This(tree.qual)(curSource))

0 commit comments

Comments
 (0)