Skip to content

Fix #2360: Fix inlined module ref. #2364

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions compiler/src/dotty/tools/dotc/typer/Inliner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions tests/run/i2360.check
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
42
15 changes: 15 additions & 0 deletions tests/run/i2360.scala
Original file line number Diff line number Diff line change
@@ -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
}