Skip to content

Commit c3526e2

Browse files
committed
Fix #2265: Make new symbols for inlined module proxies.
1 parent 2f85c86 commit c3526e2

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -366,9 +366,11 @@ class Inliner(call: tpd.Tree, rhs: tpd.Tree)(implicit ctx: Context) {
366366
case tpe: ThisType
367367
if !ctx.owner.isContainedIn(tpe.cls) && !tpe.cls.is(Package) &&
368368
!thisProxy.contains(tpe.cls) =>
369-
if (tpe.cls.isStaticOwner)
370-
thisProxy(tpe.cls) = tpe.cls.sourceModule.termRef
371-
else {
369+
if (tpe.cls.isStaticOwner) {
370+
val proxyName = s"${tpe.cls.name}_module".toTermName
371+
val proxyType = tpe.cls.sourceModule.termRef
372+
thisProxy(tpe.cls) = newSym(proxyName, EmptyFlags, proxyType).termRef
373+
} else {
372374
val proxyName = s"${tpe.cls.name}_this".toTermName
373375
val proxyType = tpe.asSeenFrom(prefix.tpe, meth.owner)
374376
thisProxy(tpe.cls) = newSym(proxyName, EmptyFlags, proxyType).termRef

tests/run/inline-object.check

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
bar

tests/run/inline-object.scala

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
object Test {
3+
def main(args: Array[String]): Unit = {
4+
Foo.foo
5+
}
6+
}
7+
8+
object Foo extends Bar {
9+
inline def foo: Unit = bar
10+
}
11+
12+
class Bar {
13+
def bar: Unit = println("bar")
14+
}

0 commit comments

Comments
 (0)