Sample code with two overload methods (Scala 2.11.8), as expected:
def foo(p: Int, t: Double): Unit = {} def foo(r: Int => Double): Unit = {} foo(0, 0) // 1st method foo(x => x.toDouble) // 2nd method
The same code with the general parameter added:
def fooGeneric[T](p: T, t: Double): Unit = {} def fooGeneric[T](r: T => Double): Unit = {} fooGeneric[Int](1, 1) // 1st method fooGeneric[Int]((x: Int) => x.toDouble) //2nd method fooGeneric[Int](x => x.toDouble) // does not compile
throws the following compilation error:
Error:(112, 19) missing parameter type fooGeneric[Int](x => x.toDouble)
There seems to be no ambiguity in the resolution of the method, but the compiler does not find a match. Why?
source share