Why does Stream.of() require a cast to take an inline lambda expression or method reference?
Consider this:
Function<String,String> f = String::toUpperCase; // works without cast
Stream.of(f); // works without cast
//Stream.of(String::toUpperCase); // Error - target type must be functional interface
Stream.of((Function<String,String>) String::toUpperCase); //OK
The assignment to the variable f does not require a cast, but when used as an inline parameter to Stream.of a cast is required. Why?