separate capture conversion from substitution

This commit is contained in:
Anna Kozlova
2015-04-27 09:32:20 +02:00
parent 577b88c24e
commit 21f187bd44
5 changed files with 94 additions and 131 deletions
@@ -15,14 +15,14 @@
*/
package pck;
interface A<T>
interface A<T>
{
T foo();
}
interface B<T extends Cloneable> extends A<T> { }
class C<T extends A<?> & B<?>>
class C<T extends A<? extends Cloneable> & B<?>>
{
void bar(T x)
{
@@ -19,7 +19,7 @@ class SortTest<R extends Comparable<R>> implements Comparable<SortTest<R>> {
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>;
t1.compareTo<error descr="'compareTo(SortTest<capture<? extends java.lang.Comparable<capture<?>>>>)' in 'SortTest' cannot be applied to '(SortTest<capture<?>>)'">(t2)</error>;
t1.compareTo<error descr="'compareTo(SortTest<capture<? extends java.lang.Comparable<capture<?>>>>)' in 'SortTest' cannot be applied to '(SortTest<capture<? extends java.lang.Comparable<capture<?>>>>)'">(t2)</error>;
//this should be OK
SortTest<?>[] arr = new SortTest<?>[0];
@@ -19,7 +19,7 @@ class SortTest<R extends Comparable<R>> implements Comparable<SortTest<R>> {
SortTest<?> t2 = new SortTest<Integer>(0);
list.add(t2);
Collections.sort<error descr="'sort(java.util.List<T>)' in 'java.util.Collections' cannot be applied to '(java.util.ArrayList<SortTest<?>>)'">(list)</error>;
t1.compareTo<error descr="'compareTo(SortTest<capture<? extends java.lang.Comparable<capture<?>>>>)' in 'SortTest' cannot be applied to '(SortTest<capture<?>>)'">(t2)</error>;
t1.compareTo<error descr="'compareTo(SortTest<capture<? extends java.lang.Comparable<capture<?>>>>)' in 'SortTest' cannot be applied to '(SortTest<capture<? extends java.lang.Comparable<capture<?>>>>)'">(t2)</error>;
//this should be OK
SortTest<?>[] arr = new SortTest<?>[0];