Open
Description
reproduction steps
trait T[-X, +Y] {
def apply(x: X): Y
def g[Z](t: T[Y, Z]): T[X, Z] = ???
def g[Z](m: Y => Z): T[X, Z] = ???
def f[W](t: T[W, X]): T[W, Y] = t.g(this)
}
problem
SO.scala:5: error: type mismatch;
found : T[X,Y]
required: W => ?
def f[W](t: T[W, X]): T[W, Y] = t.g(this)
^
expectation
By commenting out the apply
method, overload resolution proceeds as expected.
Explicitly annotating t.g[Y](this)
also works around the behavior.
Maybe if assisted type inference ("higher-order function type parameter inference") fails during overload resolution, it could fall back to the old behavior and type check with unexpected type and correspondingly low expectations.