captured wildcards: don't open unpredictably, treat as type, not type argument (IDEA-148348)

This commit is contained in:
Anna Kozlova
2015-11-26 19:23:09 +01:00
parent f7e9660f0d
commit e43fad4277
12 changed files with 63 additions and 25 deletions
@@ -0,0 +1,20 @@
import java.util.Collection;
interface C<K extends String> extends Collection<K> {}
class Test {
C<?> id;
static <T extends CharSequence> T get(Collection<? extends T> id) {
return null;
}
String getObj() {
return get( id);
}
}
@@ -4,40 +4,40 @@ abstract class A<T> {
<K> void baz253(B<? super K, ?> a) {}
abstract B<? super T, ? super T> foo253();
void bar253(A<?> a) {
baz253<error descr="'baz253(B<? super K,?>)' in 'A' cannot be applied to '(B<capture<? super capture<?>>,capture<? super capture<?>>>)'">(a.foo253())</error>;
baz253(a.foo253());
}
<K> void baz255(B<? super K, ?> a) {}
abstract B<? super T, ? super T> foo255();
void bar255(A<? extends T> a) {
baz255<error descr="'baz255(B<? super K,?>)' in 'A' cannot be applied to '(B<capture<? super capture<? extends T>>,capture<? super capture<? extends T>>>)'">(a.foo255())</error>;
baz255(a.foo255());
}
<K> void baz256(B<? super K, ?> a) {}
abstract B<? super T, ? extends T> foo256();
void bar256(A<?> a) {
baz256<error descr="'baz256(B<? super K,?>)' in 'A' cannot be applied to '(B<capture<? super capture<?>>,capture<? extends capture<?>>>)'">(a.foo256())</error>;
baz256(a.foo256());
}
<K> void baz258(B<? super K, ?> a) {}
abstract B<? super T, ? extends T> foo258();
void bar258(A<? extends T> a) {
baz258<error descr="'baz258(B<? super K,?>)' in 'A' cannot be applied to '(B<capture<? super capture<? extends T>>,capture<? extends T>>)'">(a.foo258())</error>;
baz258(a.foo258());
}
<K> void baz259(B<? super K, ?> a) {}
abstract B<? super T, ?> foo259();
void bar259(A<?> a) {
baz259<error descr="'baz259(B<? super K,?>)' in 'A' cannot be applied to '(B<capture<? super capture<?>>,capture<?>>)'">(a.foo259())</error>;
baz259(a.foo259());
}
<K> void baz261(B<? super K, ?> a) {}
abstract B<? super T, ?> foo261();
void bar261(A<? extends T> a) {
baz261<error descr="'baz261(B<? super K,?>)' in 'A' cannot be applied to '(B<capture<? super capture<? extends T>>,capture<?>>)'">(a.foo261())</error>;
baz261(a.foo261());
}
}