new inference: reject contradicting equals bounds

This commit is contained in:
Anna Kozlova
2014-12-17 09:57:47 +01:00
parent e0b2d2d8f0
commit f217ed47c4
7 changed files with 32 additions and 8 deletions
@@ -9,8 +9,8 @@ class B<L> {
void bar(B<?> b, A<?, ?> foo1) {
baz(b.foo());
A<?, ?> foo = b.foo();
baz<error descr="'baz(A<capture<?>,capture<?>>)' in 'B' cannot be applied to '(A<capture<?>,capture<?>>)'">(foo)</error>;
baz<error descr="'baz(A<capture<?>,capture<?>>)' in 'B' cannot be applied to '(A<capture<?>,capture<?>>)'">(foo1)</error>;
baz<error descr="'baz(A<java.lang.Object,java.lang.Object>)' in 'B' cannot be applied to '(A<capture<?>,capture<?>>)'">(foo)</error>;
baz<error descr="'baz(A<java.lang.Object,java.lang.Object>)' in 'B' cannot be applied to '(A<capture<?>,capture<?>>)'">(foo1)</error>;
}
<K> void baz(A<K, K> a) {
@@ -18,7 +18,7 @@ class SortTest<R extends Comparable<R>> implements Comparable<SortTest<R>> {
list.add(t1);
SortTest<?> t2 = new SortTest<Integer>(0);
list.add(t2);
<error descr="Inferred type 'SortTest<?>' for type parameter 'T' is not within its bound; should implement 'java.lang.Comparable<? super SortTest<?>>'">Collections.sort(list)</error>;
<error descr="Inferred type 'java.lang.Object' for type parameter 'T' is not within its bound; should implement 'java.lang.Comparable<? super java.lang.Object>'">Collections.sort(list)</error>;
t1.compareTo<error descr="'compareTo(SortTest<capture<? extends java.lang.Comparable<capture<?>>>>)' in 'SortTest' cannot be applied to '(SortTest<capture<?>>)'">(t2)</error>;
//this should be OK
@@ -0,0 +1,15 @@
class B<T1,S> {}
abstract class A<T> {
<K> void baz35(B<K, ? extends K> a) {}
abstract B<T,? super T> foo35();
void bar35(A<? super T> a){
baz35<error descr="'baz35(B<java.lang.Object,?>)' in 'A' cannot be applied to '(B<capture<? super T>,capture<? super T>>)'">(a.foo35())</error>;
}
<K> void baz44(B<K, ? extends K> a) {}
abstract B<? super T,? super T> foo44();
void bar44(A<? super T> a){
baz44<error descr="'baz44(B<java.lang.Object,?>)' in 'A' cannot be applied to '(B<capture<? super T>,capture<? super T>>)'">(a.foo44())</error>;
}
}
@@ -47,7 +47,7 @@ class Test {
}
void bug1(Parametrized<? super T> param) {
<error descr="Inferred type 'capture<? super T>' for type parameter 'I' is not within its bound; should extend 'java.lang.Number'">foo(param)</error>;
foo<error descr="'foo(Test.Parametrized<java.lang.Number>)' in 'Test.Bug2' cannot be applied to '(Test.Parametrized<capture<? super T>>)'">(param)</error>;
}
@@ -152,7 +152,7 @@ class S2 {
}
void bar(List<? extends S2> k) {
f<error descr="'f(java.util.List<capture<? extends S2>>, java.util.List<capture<? extends S2>>)' in 'S2' cannot be applied to '(java.util.List<capture<? extends S2>>, java.util.List<capture<? extends S2>>)'">(k, k)</error>;
f<error descr="'f(java.util.List<java.lang.Object>, java.util.List<java.lang.Object>)' in 'S2' cannot be applied to '(java.util.List<capture<? extends S2>>, java.util.List<capture<? extends S2>>)'">(k, k)</error>;
}
}
@@ -162,7 +162,7 @@ class S3 {
}
void bar(Map<? extends S3, ? extends S3> k) {
f<error descr="'f(java.util.Map<capture<? extends S3>,capture<? extends S3>>)' in 'S3' cannot be applied to '(java.util.Map<capture<? extends S3>,capture<? extends S3>>)'">(k)</error>;
f<error descr="'f(java.util.Map<java.lang.Object,java.lang.Object>)' in 'S3' cannot be applied to '(java.util.Map<capture<? extends S3>,capture<? extends S3>>)'">(k)</error>;
}
}