because of the way type inference works in scala, it is unable to determine the what the type parameter to last
has to be, so it has to take the overly conservative fallback guess that it is Nothing
.
You can explicitly specify the types when you call testFunction
:
testFunction[List[Int],Option[Int](last, testValues)
or you can document more fully the relationship between the type parameters in the testFunction
declaration, which will give the type inferencer more information:
def testFunction[A, I[_], O[_]](f : I[A] => O[A], inputs : List[I[A]]): List[(I[A], O[A])]
This explicitly says that I and O are type constructors (kind * -> *), now that the input/output types of f are more specific, the inferencer can correctly infer that the A parameter to the the last function must be Int.