checker-framework
checker-framework copied to clipboard
type.argument warning when assigning to explicitly retyped type with wildcard parameters
using checker 3.49.5
Following code
public class Test<T, L extends List<@Nullable T>> {
void method(Object x) {
Test<?, ?> y = (Test<?, ?>) x;
}
}
produces warning
java: [type.argument] incompatible type argument for type parameter L of Test.
found : capture#01[ extends @Initialized @NonNull List<capture#02[ extends @Initialized @Nullable Object super @Initialized @NonNull Void]> super @Initialized @NonNull Void]
required: @Initialized @NonNull List<capture#02[ extends @Initialized @Nullable Object super @Initialized @Nullable Void]>
I believe there is no reason for warning
Any idea how I can workaround this? I have the problem on a field declaration e.g.
class Main {
List<MyClass<?, ?>> list;
}
class MyClass<X, Y extends X> {}
It fails compilation with the same error as above
error: [type.argument] incompatible type argument for type parameter Y of MyClass.
private List<MyClass<?,?>> treats;
^
found : @Initialized @NonNull Object
required: capture#07 extends @Initialized @Nullable Object
This a bug, but it is not related to #7346 .