-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
Description
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.