diff --git a/compiler/src/dotty/tools/dotc/typer/Inliner.scala b/compiler/src/dotty/tools/dotc/typer/Inliner.scala index cdc128143266..201af58062d6 100644 --- a/compiler/src/dotty/tools/dotc/typer/Inliner.scala +++ b/compiler/src/dotty/tools/dotc/typer/Inliner.scala @@ -409,11 +409,14 @@ class Inliner(call: tpd.Tree, rhs: tpd.Tree)(implicit ctx: Context) { var lastSelf: Symbol = NoSymbol var lastLevel: Int = 0 for ((level, selfSym) <- sortedProxies) { + lazy val rhsClsSym = selfSym.info.widenDealias.classSymbol val rhs = - if (!lastSelf.exists) - prefix - else + if (lastSelf.exists) untpd.Select(ref(lastSelf), OuterSelectName(EmptyTermName, lastLevel - level)).withType(selfSym.info) + else if (rhsClsSym.is(Module)) + ref(rhsClsSym.sourceModule) + else + prefix bindingsBuf += ValDef(selfSym.asTerm, rhs) lastSelf = selfSym lastLevel = level diff --git a/tests/run/i2360.check b/tests/run/i2360.check new file mode 100644 index 000000000000..d81cc0710eb6 --- /dev/null +++ b/tests/run/i2360.check @@ -0,0 +1 @@ +42 diff --git a/tests/run/i2360.scala b/tests/run/i2360.scala new file mode 100644 index 000000000000..d950d1c2d3dd --- /dev/null +++ b/tests/run/i2360.scala @@ -0,0 +1,15 @@ + +object Test { + def main(args: Array[String]): Unit = { + import Foo._ + println(foo) + } +} + +object Foo extends Bar { + inline def foo: Int = bar +} + +class Bar { + def bar = 42 +}