This code:
interface I {}
public class Test {
TableView<? extends I> table;
Test(ObservableList<? extends I> list) {
table = new TableView<>();
table.setItems(list);
}
}
...produces this message:
error: method setItems in class TableView<S> cannot be applied to given types;
table.setItems(list);
required: ObservableList<CAP#1>
found: ObservableList<CAP#2>
reason: argument mismatch; ObservableList<CAP#2> cannot be converted to ObservableList<CAP#1>
where S is a type-variable:
S extends Object declared in class TableView
where CAP#1,CAP#2 are fresh type-variables:
CAP#1 extends I from capture of ? extends I
CAP#2 extends I from capture of ? extends I
How can there be a type mismatch between two identical types? What am I missing?