Accepted answer

Scala is the same as Java in this respect, and the following from the "Names" chapter of the Java specification applies:

A declaration d of a type named n shadows the declarations of any other types named n that are in scope at the point where d occurs throughout the scope of d.

So the type parameter for a method will always shadow a class or trait type parameter with the same name. Your Foo example demonstrates this fact.

The apparent counterexample you're seeing in the case of Map's foldLeft is just an unpleasant artifact of the current version of Scaladoc, as is pointed out in the answers to the question you've linked. foldLeft isn't defined in the Map trait, but in TraversableOnce, where there isn't a trait type parameter named B at all.

In general shadowing the type parameter of a trait or class in a method is a really bad idea, of course.

Related Query

More Query from same tag