So I've got this super exciting Java class:
import scala.collection.immutable.Stream;
public class EmptyStreamFactory {
public static Stream<String> createEmptyStringStream() {
return Stream.<String>empty();
}
}
Compiles just fine with the 2.10.4 scala-library.jar
on the classpath (or 2.9.2, for what that's worth). Now I try it with 2.11:
EmptyStreamFactory.java:5: error: incompatible types
return Stream.<String>empty();
^
required: Stream<String>
found: GenTraversable
1 error
How does this make any sense at all? At a glance the only difference that could be remotely relevant is the fact that Stream.Empty
no longer extends Serializable
in 2.11, but I don't see how that could cause this problem. The same thing happens with List
, etc.
There's an easy workaround—you can just cast to the appropriate type—but I'd like to understand what's going on here.
(I'm on Oracle's JDK, version 1.7.0_67.)
Stream.Empty
still extendsSerializable
, because it extendsStream
. The removedSerializable
onEmpty
was superfluous, so this can't be the source of your issue. – Trying