Skip to content
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

Method references of nullable instances are not detected #919

Closed
laukerta opened this issue Feb 23, 2024 · 1 comment · Fixed by #920
Closed

Method references of nullable instances are not detected #919

laukerta opened this issue Feb 23, 2024 · 1 comment · Fixed by #920

Comments

@laukerta
Copy link

When I write

public static void doSomething(@Nullable String text) {
    return Set.of("a", "b", "c").stream().anyMatch(text::contains);
}

I receive no complains from NullAway although invoking the method reference will lead to a NPE.

If I replace the method reference by a lambda:

public static void doSomething(@Nullable String text) {
    return Set.of("a", "b", "c").stream().anyMatch(s -> text.contains(s));
}

I receive (and I expect this):

java: [NullAway] dereferenced expression text is @Nullable
    (see http://t.uber.com/nullaway )

I am using version 0.10.23.

@msridhar
Copy link
Collaborator

Great find! I will work on this as soon as I can and get a fix up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants