Skip to content

Commit af78a4c

Browse files
committed
Fix #3129: Sharpen criterion for localRefs in inlining
1 parent e5088e2 commit af78a4c

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ object Inliner {
120120

121121
// The types that are local to the inlined method, and that therefore have
122122
// to be abstracted out in the accessor, which is external to the inlined method
123-
val localRefs = qualType.namedPartsWith(_.symbol.isContainedIn(inlineMethod)).toList
123+
val localRefs = qualType.namedPartsWith(ref =>
124+
ref.isType && ref.symbol.isContainedIn(inlineMethod)).toList
124125

125126
// Abstract accessed type over local refs
126127
def abstractQualType(mtpe: Type): Type =

tests/pos/i3129.scala

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
object companions2 {
2+
inline def foo() = {
3+
class C {
4+
println(C.p)
5+
}
6+
7+
object C {
8+
private val p = 1
9+
}
10+
}
11+
}
12+
13+
class A {
14+
val b = new B
15+
16+
class B {
17+
private def getAncestor2(p: A): A = p
18+
private inline def getAncestor(p: A): A = {
19+
p.b.getAncestor(p)
20+
}
21+
}
22+
}

0 commit comments

Comments
 (0)