-
Bug
-
Resolution: Cannot Reproduce
-
P4
-
8
This should compile but fails in javac 8 b121:
Stream<Optional<? extends U>> s = null;
Stream<U> s2 = s.map(Optional::get);
error: incompatible types: inference variable R has incompatible bounds
Stream<Number> s2 = s.map(Optional::get);
^
equality constraints: Number
lower bounds: ? extends Number
where R,T are type-variables:
R extends Object declared in method <R>map(Function<? super T,? extends R>)
T extends Object declared in interface Stream
Looks like there's a failure to capture '? extends Number', as specified by JLS 15.13.1: "If the ReferenceType [Optional] is a raw type, and there exists a parameterization of this type, T, that is a supertype of P1 [Optional<? extends U>], the type to search is the result of capture conversion (5.1.10) applied to T"
Stream<Optional<? extends U>> s = null;
Stream<U> s2 = s.map(Optional::get);
error: incompatible types: inference variable R has incompatible bounds
Stream<Number> s2 = s.map(Optional::get);
^
equality constraints: Number
lower bounds: ? extends Number
where R,T are type-variables:
R extends Object declared in method <R>map(Function<? super T,? extends R>)
T extends Object declared in interface Stream
Looks like there's a failure to capture '? extends Number', as specified by JLS 15.13.1: "If the ReferenceType [Optional] is a raw type, and there exists a parameterization of this type, T, that is a supertype of P1 [Optional<? extends U>], the type to search is the result of capture conversion (5.1.10) applied to T"