|
Relates :
|
This will not compile:
void test(Box<? extends Box<? extends Number>> b) {
Number n = b.map(Box::get).get();
}
interface Func<S,T> { T apply(S arg); }
interface Box<T> {
T get();
<R> Box<R> map(Func<T,R> f);
}
error: incompatible types: inferred type does not conform to upper bound(s)
Number n = b.map(Box::get).get();
^
inferred: ? extends Number
upper bound(s): Object
If I remove the wildcards, there is no error.
Perhaps javac is failing to capture the return type of Box.get?
|