Why, when subclassing a generic class without specifying a type, does every other common type of the parent class be considered a simple type in subclasses?
For example, the following gives an error since s is not a Map <Integer, String>, but a simple map.
class Foo<T> {
protected Map<Integer, String> s;
}
class Bar extends Foo {
public Bar() {
s.get(0).length();
}
}
Of course, if Bar extends Foo <Whatever happens, the error disappears.
source
share