Open
Description
As reported in https://gitter.im/scala/contributors?at=5d5bdd557d56bc60808ddfd3, SAM overload resolution doesn't work in this case:
trait SAM[A, B] { def foo(a: A): B }
def foo(sam: SAM[Int, String]): String = ???
def foo(sam: SAM[Int, Unit]): Unit = ???
foo(x => x.toString)
The problem is in OverloadedArgProto.toWild
which was introduced with the changes in scala/scala#6871. One of the cases that should be supported is:
: all overloads expect a SAM type of the same class, but with potentially varying result types
(argument types must be =:=
)
This is supposed to be handled in scala/scala@cd70540#diff-ecaa4198a04261cd0e00a708b695eafbR1316 but toWild
only erases undetermined type params. It should also erase already instantiated type params which are irrelevant for the parameter types of the SAMs.