Surprising behavior of `@NullUnmarked` on method overriding `Map.get()`
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 4.1k
- Forks
- 370
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 68
Description
Test case:
A user may expect that annotating the TestMap.get() method as @NullUnmarked would lead to its return being treated as @NonNull. But, our rules dictate that for unannotated code, inherited library models should apply. So, the inherited library model for Map.get() is applied, and the return becomes @Nullable. Not sure whether we need to fix something here, or whether this is unusual but sensible behavior. My intuition is that an explicit @NullUnmarked annotation should "win" over an inherited library method, but that will just make the rules even more complicated...
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 with the linked test in nullaway/src/test/java/com/uber/nullaway/NullAwayJSpecifyTests.java, lines 1138-1151, and trace how inherited library models are applied to TestMap.get(). Determine the intended precedence between explicit @NullUnmarked and the Map.get() model; done means a documented decision and a regression test for the chosen behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100