Duplicate :
|
|
Duplicate :
|
|
Relates :
|
This code: interface Iface<T1> {} class Impl implements Iface<Impl> {} class Acceptor<T2 extends Iface<T2>> { public Acceptor(T2 obj) {} } public class Test { public static void main(String[] args) { Acceptor<?> acceptor = new Acceptor<>(new Impl()); } } which is accepted by javac 7 is rejected by javac 8 with this error message: Test.java:11: error: incompatible types: cannot infer type arguments for Acceptor<> Acceptor<?> acceptor = new Acceptor<>(new Impl()); ^ reason: inference variable T2 has incompatible bounds equality constraints: Impl upper bounds: Iface<CAP#1>,Iface<T2> where T2 is a type-variable: T2 extends Iface<T2> declared in class Acceptor where CAP#1 is a fresh type-variable: CAP#1 extends Iface<CAP#1> from capture of ? 1 error
|