-
Notifications
You must be signed in to change notification settings - Fork 331
Description
This is a follow-up to #1377. In #1378 we address #1377 in a rather hacky way, by deciding unconditionally to use the type on the IdentifierTree for variables whose type is a type var, and to use the type on the corresponding Symbol otherwise. What we should probably do instead is take the type on the IdentifierTree and then restore explicit type-use annotations from the type of the Symbol. This way we will preserve any other substitutions that javac has done. For the specific example from #1377:
package org.example;
interface Marker {}
class Generic<T> {
public void method() {}
}
class Base<T extends Object & Marker> {
T instance;
}
class SubClass<T extends Generic<Integer> & Marker> extends Base<T> {
void method() {
instance.method();
}
}If you get the type of the Symbol for instance, you'll get the T type variable declared on Base, whose upper bound is Object & Marker. But, if you get the type of the instance IdentifierTree, then given instance is being used within SubClass, you get back the T type variable of SubClass whose upper bound is Generic<Integer> & Marker, as desired. So this is why the "fix" in #1378 works for this case. But, as noted above, I think we should try to do something more general / principled.