Skip to content

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

Closed
@smarter

Description

@smarter

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions