bug
bug copied to clipboard
diverging implicit with context bounds
The order of implicit parameters matters during use site-inference.
The method definitions below successfully compile. Actually using y and z yields a compile-time error with message: "diverging implicit expansion for type Ordering[A] starting with method Tuple9 in object Ordering"
def x[A, B](b: B)(implicit t: B => Traversable[A], o: Ordering[A]) = b
def y[A, B](b: B)(implicit o: Ordering[A], t: B => Traversable[A]) = b
def z[A: Ordering, B](b: B)(implicit t: B => Traversable[A]) = b
val ls = List(42)
x(ls) // works
y(ls) // compile time-error
z(ls) // compile time-error
Imported From: https://issues.scala-lang.org/browse/SI-7205?orig=1 Reporter: Martin Egri (teknocide) Affected Versions: 2.10.1-RC1, 2.10.1
Remains reproducible in Scala 2.13.16.
Scala 3.6.3 gives similar errors, e.g. Ambiguous given instances: both object Byte in object Ordering and object String in object Ordering match type Ordering[Any] of parameter o of method y
(I haven't considered if this is a bug, or if it's working-as-designed.)