See this example:
def hello(a:String, b:String) = println(a + ":" + b)
val m1 = hello("aaa", _ )
m1("bbb")
It can’t be compiled, that I need to add the type to the partial method:
val m1 = hello("aaa", _: String)
Why scala doesn’t know the 2nd parameter of method hello is String?
Scala’s type inference is flow based. Methods and functions need explicit parameter types, which are used to infer other types. The parameter types cannot be inferred from method or function body. Sometimes, however, the parameter types are known from external context, and then don’t have to be labeled. Two examples,
Below is a quote from Martin Odersky about the limitations of Scala’s type inference compared to, say, ML and Haskell. Challenges include Scala’s overloading, record selection, and subtyping, as well as the need to keep things simple,
Source: comment under post Universal Type Inference is a Bad Thing.