Let's say I've got this function:
Table<Record> tableOfRecord() {}
And a type TableRecord<R extends TableRecord> extends Record
. And I have this other function:
<R extends TableRecord<R>> Table<R> table(Table<R> table, String filtered) {
// ...
return (Table<R>) tableOfRecord();
}
The above fails to compile:
error: incompatible types: Table<Record> cannot be converted to Table<R>
However, this compiles and runs fine:
return (Table<R>) ((Table<?>) tableOfRecord());
I am not sure why this is allowed, but the previous example is not.