In the following session with scala 2.10.0-M7:
scala> trait A
defined trait A
scala> class B extends A
defined class B
scala> class C extends A
defi
This is a general limitation of the type inference algorithm. The folding across lists has the same limitation. To quote Programming in Scala:
Note that both versions of flatten require a type annotation on the empty list that is the start value of the fold. This is due to a limitation in Scala's type inferencer, which fails to infer the correct type of the list automatically.
Scala's type inference algorithm works incrementally across methods with multiple parameter lists. Types specified in the first can be used for inference in the second, the second in the third, etc. As outlined in the style guide, this allows you to use simpler syntax in the fold functions since the inference engine knows the type of the list and the accumulator's type from the first argument list.
However, since it works incrementally across successive parameter lists the inference engine won't go back and update the return type (which is the same as the accumulator type) after inferring the type of the function argument to fold. Instead you get a type error.
In your example above, just give a type annotation on your accumulator value and you'll be good:
Some(0).fold(new B: A){_=>new C}