Why does the below code fail to compile? Can this example be simplified (to fewer classes) to demonstrate equivalent error?
The error message produced is:
func(capture of ? extends A) in ... cannot be aplied to B
private static interface A {}
private static class B implements A {}
private static class C<T> {
private final T t;
private C(T t) {
this.t = t;
}
private void func(T t) {}
}
@Test
public void doTest() {
B b = new B();
C<? extends A> c = new C<B>(b);
c.func(b); // fails here
}