Here is an SSCCE:
import java.util.*;
class Test {
public static void main(String[] args) {
bar( foo() );
}
public static List<? extends CharSequence> foo() {
return null;
}
public static void bar(List<CharSequence> baz) {
// Nothing to see here
}
}
This results in
bar(java.util.List<java.lang.CharSequence>) in Test cannot be applied to (java.util.List<capture#672 of ? extends java.lang.CharSequence>)
- Is there any possible way in which this example could fail? It is safe to cast
<? extends CharSequence>
to<CharSequence>
, isn't it? - How should I work around this (in a more complex setup) if not via casting?