@@ -1333,10 +1333,17 @@ object Trees {
13331333 case tree : SeqLiteral if (elems eq tree.elems) && (elemtpt eq tree.elemtpt) => tree
13341334 case _ => finalize(tree, untpd.SeqLiteral (elems, elemtpt)(sourceFile(tree)))
13351335 }
1336- def Inlined (tree : Tree )(call : tpd.Tree , bindings : List [MemberDef ], expansion : Tree )(using Context ): Inlined = tree match {
1337- case tree : Inlined if (call eq tree.call) && (bindings eq tree.bindings) && (expansion eq tree.expansion) => tree
1338- case _ => finalize(tree, untpd.Inlined (call, bindings, expansion)(sourceFile(tree)))
1339- }
1336+ // Positions of trees are automatically pushed down except when we reach an Inlined tree. Therefore, we
1337+ // make sure the new expansion has a position by copying the one of the original Inlined tree.
1338+ def Inlined (tree : Inlined )(call : tpd.Tree , bindings : List [MemberDef ], expansion : Tree )(using Context ): Inlined =
1339+ if (call eq tree.call) && (bindings eq tree.bindings) && (expansion eq tree.expansion) then tree
1340+ else
1341+ // Copy the span from the original Inlined tree if the new expansion doesn't have a span.
1342+ val expansionWithSpan =
1343+ if expansion.span.exists then expansion
1344+ else expansion.withSpan(tree.expansion.span)
1345+ finalize(tree, untpd.Inlined (call, bindings, expansionWithSpan)(sourceFile(tree)))
1346+
13401347 def Quote (tree : Tree )(body : Tree , tags : List [Tree ])(using Context ): Quote = tree match {
13411348 case tree : Quote if (body eq tree.body) && (tags eq tree.tags) => tree
13421349 case _ => finalize(tree, untpd.Quote (body, tags)(sourceFile(tree)))
0 commit comments