Duplicate :
|
|
Duplicate :
|
|
Relates :
|
The following compiles in 8 but fails to compile current in 9: import java.util.ArrayList; import java.util.List; public class CaptureInference { public List<String> l; public CaptureInference() { l = new ArrayList<>(get(String.class)); } public static <T> List<? extends T> get(Class<T> clazz) { return null; } } /* String.class -> Class<t> Class<String> -> Class<t> { t = String } List<? extends t> -> Collection<? extends e> { t = String, z <: Object, List<z> = capture(List<? extends t>) } List<z> -> Collection<? extends e> { t = String, z <: Object, z <: e, List<z> = capture(List<? extends t>) } ArrayList<e> -> List<String> { t = String, e = String, z <: Object, z <: e, List<z> = capture(List<? extends t>) } */
|