-
Notifications
You must be signed in to change notification settings - Fork 21
Open
Labels
fixed in Scala 3This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)inferoverloadingsam
Milestone
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.
Metadata
Metadata
Assignees
Labels
fixed in Scala 3This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)inferoverloadingsam