Skip to content

Incorrect ambiguous reference error when imports are shadowed by local definition #2324

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

Closed
smarter opened this issue Apr 28, 2017 · 0 comments

Comments

@smarter
Copy link
Member

smarter commented Apr 28, 2017

The following code emits an error in dotty but not scalac:

object A {
  def foo: Int = 1
}
object B {
  def foo: Int = 2
}
object C {
  import A._
  import B._

  def foo: Int = 3

  println(foo)
}
13 |  println(foo)
   |          ^^^
   |          reference to `foo` is ambiguous
   |          it is both imported by import A._
   |          and imported subsequently by import B._

This is of course incorrect, the reference is not ambiguous, it must be C.foo.

odersky added a commit that referenced this issue Apr 28, 2017
Fix #2324: Check contexts in right order when looking for idents
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant