Skip to content
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

"Ambiguous" imports collide with object definitions #7876

Closed
travisbrown opened this issue Dec 30, 2019 · 0 comments
Closed

"Ambiguous" imports collide with object definitions #7876

travisbrown opened this issue Dec 30, 2019 · 0 comments

Comments

@travisbrown
Copy link
Contributor

minimized code

object foo
object bar

import foo._, bar._

object eq

expectation

This should compile, but instead it fails with this error:

-- [E049] Reference Error: eq.scala:6:0 ----------------------------------------
6 |object eq
  |^
  |Reference to eq is ambiguous
  |it is both imported by import foo._
  |and imported subsequently by import bar._

Explanation
===========
The compiler can't decide which of the possible choices you
are referencing with eq.
Note:
- Definitions take precedence over imports
- Named imports take precedence over wildcard imports
- You may replace a name when imported using
  import scala.{ eq => eqTick }

The same things happen if instead of eq you have a definition explicitly defined on the objects.

If you only have a single eq method import, it compiles just fine. If you replace object eq with trait eq it's also fine.

liufengyun added a commit that referenced this issue Jan 7, 2020
Fix #7876: Hold off with uniqueness checking for imports
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