Skip to content

Commit 8c73189

Browse files
authored
Merge pull request #2269 from dotty-staging/fix-#2265
Fix #2265: Make new symbols for inlined module proxies.
2 parents 3dca14d + 2f21f2f commit 8c73189

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -366,14 +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 {
372-
val proxyName = s"${tpe.cls.name}_this".toTermName
373-
val proxyType = tpe.asSeenFrom(prefix.tpe, meth.owner)
374-
thisProxy(tpe.cls) = newSym(proxyName, EmptyFlags, proxyType).termRef
369+
val proxyName = s"${tpe.cls.name}_this".toTermName
370+
val proxyType = tpe.asSeenFrom(prefix.tpe, meth.owner)
371+
thisProxy(tpe.cls) = newSym(proxyName, EmptyFlags, proxyType).termRef
372+
if (!tpe.cls.isStaticOwner)
375373
registerType(meth.owner.thisType) // make sure we have a base from which to outer-select
376-
}
377374
case tpe: NamedType
378375
if tpe.symbol.is(Param) && tpe.symbol.owner == meth &&
379376
!paramProxy.contains(tpe) =>

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)