new inference: infinite types

This commit is contained in:
Anna Kozlova
2014-08-28 14:28:50 +04:00
parent c1bae4745f
commit 495e455ded
4 changed files with 84 additions and 26 deletions
@@ -1,7 +1,16 @@
import java.util.List;
class Sample {
<T extends List<K>, K extends List<T>> void foo(){}
<T extends List<K>, K extends List<T>> T foo(){
<error descr="Incompatible types. Found: 'K', required: 'T'">T t = foo().get(0);</error>
<error descr="Incompatible types. Found: 'K', required: 'K'">K k = foo().get(0);</error>
<error descr="Incompatible types. Found: 'T', required: 'T'">T t1 = foo().get(0).get(0);</error>
String s = foo();
<error descr="Incompatible types. Found: 'K', required: 'java.lang.String'">String s1 = foo().get(0);</error>
return null;
}
{
foo();
@@ -3,5 +3,5 @@ import java.util.Map;
public class SOE {
public static <K extends M, M extends Map<K,M>> M foo() {return null;}
public static <K1 extends M1, M1 extends Map<K1,M1>> Map<K1, M1> foo1() {return <error descr="Inferred type 'java.util.Map<K1,M1>' for type parameter 'M' is not within its bound; should implement 'java.util.Map<java.util.Map<K1,M1>,java.util.Map<K1,M1>>'">foo()</error>;}
public static <K1 extends M1, M1 extends Map<K1,M1>> Map<K1, M1> foo1() {<error descr="Incompatible types. Found: 'M', required: 'java.util.Map<K1,M1>'">return foo();</error>}
}