-
Notifications
You must be signed in to change notification settings - Fork 21
Open
Description
Consider the following cocde:
object Priority {
class Ev[-A, +B]
class Foo[A]
class Quux
// Foo is associated with Bar
// Quux is part of Foo
class Bar extends Foo[Quux]
object Foo {
implicit val ev: Ev[Any, Boolean] = new Ev
}
object Bar {
implicit val ev: Ev[Any, String] = new Ev
}
object Quux {
implicit val ev: Ev[Any, Int] = new Ev
}
// Here we require an implicit parameter of type `Ev[Bar, ?]`.
// Candidates will be looked up from the companion objects of the
// types associated with `Bar`: `Bar`, `Foo` and `Quux`
def usage[X](implicit ev: Ev[Bar, X]): Unit = ()
usage
}We get ambiguous candidates: Quux.ev and Bar.ev. Note that Foo.ev has a lower priority and does not cause ambiguity. I would expect Quux.ev to also have a lower priority because it is defined in the companion of a type (Quux) which is part of a type (Foo[Quux]) which is associated with Bar.
Metadata
Metadata
Assignees
Labels
No labels