Missing check for library models for lambdas with an expression body
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 4.1k
- Forks
- 370
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 68
Description
In our handling of lambdas, we immediately bail out of all checking if the corresponding functional interface method is unannotated:
But, this skips a check that is later performed for return types, where we allow library models to override return type nullability:
In particular, we model Guava Functions as having a @NonNull return, but if you write (x) -> null and pass it as a Guava Function currently NullAway does not report an error. In contrast, writing (x) -> { return null; } yields an error. This should be relatively easy to fix, but it will lead to new errors when users do a NullAway update.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in nullaway/src/main/java/com/uber/nullaway/NullAway.java around lines 957-959 and compare the lambda handling with lines 875-877, where library models can override return nullability. Reproduce the Guava Function cases using expression and block lambda bodies. Done means an expression-bodied lambda returning null is checked consistently with the block-bodied form, with regression coverage added where appropriate.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 72/100