Skip to content

Commit 18a8d51

Browse files
committed
Track inlined positions from tree instead of call
1 parent c59e7aa commit 18a8d51

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

compiler/src/dotty/tools/dotc/ast/Trees.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1302,7 +1302,7 @@ object Trees {
13021302
case SeqLiteral(elems, elemtpt) =>
13031303
cpy.SeqLiteral(tree)(transform(elems), transform(elemtpt))
13041304
case Inlined(call, bindings, expansion) =>
1305-
cpy.Inlined(tree)(call, transformSub(bindings), transform(expansion)(using inlineContext(call)))
1305+
cpy.Inlined(tree)(call, transformSub(bindings), transform(expansion)(using inlineContext(tree)))
13061306
case TypeTree() =>
13071307
tree
13081308
case SingletonTypeTree(ref) =>
@@ -1440,7 +1440,7 @@ object Trees {
14401440
case SeqLiteral(elems, elemtpt) =>
14411441
this(this(x, elems), elemtpt)
14421442
case Inlined(call, bindings, expansion) =>
1443-
this(this(x, bindings), expansion)(using inlineContext(call))
1443+
this(this(x, bindings), expansion)(using inlineContext(tree))
14441444
case TypeTree() =>
14451445
x
14461446
case SingletonTypeTree(ref) =>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ class MegaPhase(val miniPhases: Array[MiniPhase]) extends Phase {
394394
case tree: Inlined =>
395395
inContext(prepInlined(tree, start)(using outerCtx)) {
396396
val bindings = transformSpecificTrees(tree.bindings, start)
397-
val expansion = transformTree(tree.expansion, start)(using inlineContext(tree.call))
397+
val expansion = transformTree(tree.expansion, start)(using inlineContext(tree))
398398
goInlined(cpy.Inlined(tree)(tree.call, bindings, expansion), start)
399399
}
400400
case tree: Return =>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
291291
case Inlined(call, bindings, expansion) if !call.isEmpty =>
292292
val pos = call.sourcePos
293293
val callTrace = Inliner.inlineCallTrace(call.symbol, pos)(using ctx.withSource(pos.source))
294-
cpy.Inlined(tree)(callTrace, transformSub(bindings), transform(expansion)(using inlineContext(call)))
294+
cpy.Inlined(tree)(callTrace, transformSub(bindings), transform(expansion)(using inlineContext(tree)))
295295
case templ: Template =>
296296
withNoCheckNews(templ.parents.flatMap(newPart)) {
297297
forwardParamAccessors(templ)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ class YCheckPositions extends Phase {
3939
assert(bindings.isEmpty)
4040
val old = sources
4141
sources = old.tail
42-
traverse(expansion)(using inlineContext(EmptyTree).withSource(sources.head))
42+
traverse(expansion)(using ctx.withSource(sources.head))
4343
sources = old
4444
case Inlined(call, bindings, expansion) =>
4545
bindings.foreach(traverse(_))
4646
sources = call.symbol.topLevelClass.source :: sources
4747
if (!isMacro(call)) // FIXME macro implementations can drop Inlined nodes. We should reinsert them after macro expansion based on the positions of the trees
48-
traverse(expansion)(using inlineContext(call).withSource(sources.head))
48+
traverse(expansion)(using inlineContext(tree).withSource(sources.head))
4949
sources = sources.tail
5050
case _ => traverseChildren(tree)
5151
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1627,7 +1627,7 @@ class Typer extends Namer
16271627

16281628
def typedInlined(tree: untpd.Inlined, pt: Type)(using Context): Tree = {
16291629
val (bindings1, exprCtx) = typedBlockStats(tree.bindings)
1630-
val expansion1 = typed(tree.expansion, pt)(using inlineContext(tree.call)(using exprCtx))
1630+
val expansion1 = typed(tree.expansion, pt)(using inlineContext(tree)(using exprCtx))
16311631
assignType(cpy.Inlined(tree)(tree.call, bindings1.asInstanceOf[List[MemberDef]], expansion1),
16321632
bindings1, expansion1)
16331633
}

0 commit comments

Comments
 (0)