Following use case
public class Test {
@Nullable Object item;
<T> @Nullable T getNullable(Class<T> type) {
return type.cast(item);
}
<T> Optional<T> getOpt(int index, Class<? extends T> type) {
return Optional.ofNullable(getNullable(type));
}
}
fails compilation in getOpt method with
java: [argument] incompatible argument for parameter type of Test.getNullable.
found : @Initialized @NonNull Class<capture#01 extends T extends @Initialized @Nullable Object>
required: @Initialized @NonNull Class<T extends @Initialized @NonNull Object>
I believe it should compile fine, as neither method makes any assumption about nullity constraints on type variable
It compiled fine with 3.42.0, fails with 3.46.0