Menu

#110 [Generics] No generic type substitution is performed

Self_Reported
open
nobody
5
2012-11-27
2006-11-16
No

In the below subclass Sub, the inherited class field t should be of type String after performing generic type substitution on the members of the supertype.

However, t seems to be treated as having type T, thus leading to the following compilation error:
File "Bug11.java", line 7, character 25 error: Variable "s" cannot be initialized by a value of type "T" [JLS 4.5.4]

==================
public class Bug11<T> {
public T t;
}

class Sub extends Bug11<String> {
public void foo() {
String s = t;
}
}
==================

Discussion


Log in to post a comment.