-
Notifications
You must be signed in to change notification settings - Fork 301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Type parameter nullability mismatch when using @Nullable T
with ? extends @Nullable T
#1126
Comments
Supplier<@Nullable String>
to type Supplier<? extends @Nullable String>
@Nullable T
with ? extends @Nullable T
I have also this use case where I have a @Contract("null -> true")
public static boolean isEmpty(@Nullable Map<?, ? extends @Nullable Object> map) {
return (map == null || map.isEmpty());
} That I try to use like: Map<String, @Nullable Object> variables = new HashMap<>();
if (CollectionUtils.isEmpty(variables)) {
// ...
} Which generates the following error:
|
@Nullable T
with ? extends @Nullable T
@Nullable T
with ? extends @Nullable T
I think this might be another example of the same: @NullMarked
class Foo {
static abstract class MyClass<T extends @Nullable Object> {
abstract T doThing(T value);
}
static void repro() {
new MyClass<@Nullable Object>() {
@Override
@Nullable Object doThing(@Nullable Object value) {
return value;
}
}.doThing(null);
}
}
|
@agrieve do you get this error with JSpecify mode enabled? Without JSpecify mode it is expected as NullAway treats all type variables as |
Yes, this is in jspecify mode. |
Ok opened #1139 for that one |
To be sure we are all on the same page, this issue is also with the JSpecify mode enabled. |
We need to handle wildcards eventually, but in the meantime, avoid reporting false positives. Fixes #1126
@sdeleuze NullAway 0.12.4 is now released with the fix for this issue and a couple of the other issues you reported |
Includes fixes to warnings introduced by the change. Main fixes are: uber/NullAway#1126 uber/NullAway#1139 uber/NullAway#1148 uber/NullAway#1151 No-try due to flaky optional windows bot. No-Try: true Bug: 389129271 Change-Id: Ia2abd8482ffabba7885b616048996f97da856b9a Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6325293 Reviewed-by: Mohamed Heikal <mheikal@chromium.org> Commit-Queue: Andrew Grieve <agrieve@chromium.org> Owners-Override: Andrew Grieve <agrieve@chromium.org> Cr-Commit-Position: refs/heads/main@{#1429012}
Includes fixes to warnings introduced by the change. Main fixes are: uber/NullAway#1126 uber/NullAway#1139 uber/NullAway#1148 uber/NullAway#1151 No-try due to flaky optional windows bot. No-Try: true Bug: 389129271 Change-Id: Ia2abd8482ffabba7885b616048996f97da856b9a Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6325293 Reviewed-by: Mohamed Heikal <mheikal@chromium.org> Commit-Queue: Andrew Grieve <agrieve@chromium.org> Owners-Override: Andrew Grieve <agrieve@chromium.org> Cr-Commit-Position: refs/heads/main@{#1429012} NOKEYCHECK=True GitOrigin-RevId: 4c17934359abc12d6cf5aef20a073285a25a2d50
I am working on enabling JSpecify mode in Spring Framework, and so far the most frequent source of issues has been the handling of
? extends @Nullable T
versus@Nullable of T
.See for example this simple code sample:
Which generates the following error:
It looks like a value use case to me, if not, please let me know.I have also the same issue with nullable method reference.
The text was updated successfully, but these errors were encountered: