You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Title sounds a bit weird, but please bear with me.
Lombok will infer Object#getClass as Class<capture of ? extends Object> instead of Class<? extends Object> or something similar. If I then use a Class#getSuperclass, I get Class<capture of ? super capture of ? extends Object rather than Class<capture of ? super Object> or such.
To Reproduce
valobj = newObject(); // doesn't matter, any type worksvartype = obj.getClass();
varsuper_type = type.getSuperclass(); // this causes a compile error, however IntelliJ isn't bothered/*Main.java:8: error: incompatible types: Class<CAP#1> cannot be converted to Class<? super Object> var super_type = type.getSuperclass(); // this causes a compile error, however IntelliJ isn't bothered ^ where CAP#1,CAP#2 are fresh type-variables: CAP#1 extends Object super: CAP#2 from capture of ? super CAP#2 CAP#2 extends Object from capture of ?*/
Expected behavior var super_type will be inferred to at the very least Class<?>.
Version info (please complete the following information):
Lombok version; 1.18.10
Platform: javac 1.8.0_222
The text was updated successfully, but these errors were encountered:
The problem here is that the signature of getSuperclass() of Class<T> returns Class<? super T>. Which makes sense. The type of the superclass of T has an upper bound of T.
However, if I have a variable of a certain type T, the value can be any subclass of T. So the type of getClass() is ? extends T. Now the lower bound is T.
We would need Class<? super (? extends T)>. That doesn't exist. The only thing that we could generate would be Class<?>.
For the resolution we depend on javac to give us the correct type. We're not sure if at that point in time we have the right information to fix this problem. We cannot replace all ? super X results, we should only do that it X is itself a wildcard (? or ? extends X, ? super X would be fine).
Describe the bug
Title sounds a bit weird, but please bear with me.
Lombok will infer
Object#getClass
asClass<capture of ? extends Object>
instead ofClass<? extends Object>
or something similar. If I then use aClass#getSuperclass
, I getClass<capture of ? super capture of ? extends Object
rather thanClass<capture of ? super Object>
or such.To Reproduce
Expected behavior
var super_type
will be inferred to at the very leastClass<?>
.Version info (please complete the following information):
The text was updated successfully, but these errors were encountered: