Hi Haddock,
Type inference in Scala works by typechecking each parameter *block* in turn, so in `fold2`, the type `T` is worked out based on the first parameter block, the least upper bound of `T` from the parameters `coll` and `seed`, and after that `T` is known and fixed. For the second parameter block, the partial function only needs to be checked as consistent with `T`; it's not being used to infer the type `T`.
The problem with the `fold` method is that Scala can't infer the domain (i.e. `(T, T)`) from a partial function literal. This often confuses people. But say, for example, that the function were this:
{ (a, b) => a + b.toInt }
which is identical to
{ _ + _.toInt }
(The underscores are pure syntactic sugar.)
This would be consistent if `T` were `Double` or `String`, which are unrelated types. Even if it could analyze, from the code, that it's a type with both a `toInt` and a `+` method on it, the compiler is no closer to knowing `T`. And, in general, it can't.
And because it can't work out this type for this one parameter, it can't work out the least upper bound of `T` for the entire expression, because `block`, along with `coll` and `seed`, necessarily contributes to that calculation of `T`.
Hope that helps!
Cheers,
Jon