Skip to content

Commit f043599

Browse files
committed
Only reposition trees from other files, not other classes
1 parent 27ab7ee commit f043599

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ object Inliner {
165165
case _ =>
166166
val transformed = super.transform(tree)
167167
enclosingInlineds match {
168-
case call :: _ if call.symbol.topLevelClass != ctx.owner.topLevelClass =>
168+
case call :: _ if call.symbol.sourceFile != ctx.owner.sourceFile =>
169169
// reposition tree inlined from some other file
170170
transformed.withPos(inlinedAtPos)
171171
case _ => transformed

tests/run/i4947c.check

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
track: Test$.main(i4947c.scala:4)
2+
track: Test$.main(i4947c.scala:5)
3+
main1: Test$.main(i4947c.scala:18)
4+
main2: Test$.main(i4947c.scala:19)

tests/run/i4947c.scala

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
object Aux {
2+
3+
transparent def track[T](f: => T): T = {
4+
printStack("track")
5+
printStack("track")
6+
f
7+
}
8+
9+
def printStack(tag: String): Unit = {
10+
println(tag + ": "+ new Exception().getStackTrace().apply(1))
11+
}
12+
}
13+
14+
object Test {
15+
import Aux._
16+
def main(args: Array[String]): Unit = {
17+
track {
18+
printStack("main1")
19+
printStack("main2")
20+
}
21+
}
22+
23+
}

0 commit comments

Comments
 (0)