You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I haven't spent much time with dotty yet, but the dotty spec change is misleading in terms of Scala 2. Static overloading already prefers f(X) to f(=>X) when the relative weight is the same, so the dotty spec example should just continue to compile.
Here, conversion prefers by-value because of the two-pass rule, but overloading prefers by-name because it is more specific.
case class C(i: Int)
object C extends Imps {
implicit def f(b: => B): C = C(42)
}
class Imps {
implicit def f(a: A): C = C(17)
}
class A
class B extends A
object Main {
def main(args: Array[String]) = println {
(null.asInstanceOf[A] : C, C.f(null.asInstanceOf[B])). // (C(17),C(42))
}
}
The same experiment with both in C differing only in by-name
implicit def g(a: => A): C = C(42)
implicit def g(a: A): C = C(17)
for dotty compat, see scala/scala3#5633
The text was updated successfully, but these errors were encountered: