Decouple synthetic nullness annotations from VisitorState

Open
#2,073 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Active
Tech stack
java
Domain
backend, testing

Research direction

Read GenericsChecks.getSyntheticNullableAnnotType and getSyntheticNonNullAnnotType, RestoreNullnessAnnotationsVisitor, and the discussion on PR #1972. Trace captured-type annotation recovery to separate semantic restoration from obtaining an annotation object, preserving inferred capture nullability, explicit type-variable annotations, intersection bounds, and compiler-owned type isolation. Validate any cleanup with ordinary diagnostic tests for wildcard captures and intersection inference, including the generic call inside the constructor lambda from #1972.

Written by the indexing model from the issue text.

Description

Note that this issue has been framed with agentic help (GPT 6.1).

Follow-up requested in https://github.com/uber/NullAway/pull/1972#discussion_r4368635862.

GenericsChecks.getSyntheticNullableAnnotType and getSyntheticNonNullAnnotType currently require VisitorState to access javac Names and Symtab. RestoreNullnessAnnotationsVisitor does not have a VisitorState, and its captured-type handling retrieves and reuses a synthetic annotation from another type through getDirectSyntheticNullnessAnnotation.

Investigate whether synthetic annotation creation can depend on a narrower compiler context, or whether annotation types can be supplied explicitly to restoration, so that the workaround and annotation-recovery helper can be simplified. Confirm which parts of the helper are required for semantic restoration rather than merely for obtaining an annotation object before removing anything.

Preserve the distinction between inferred capture nullability and explicit type-variable use annotations, structural handling of intersection bounds, and isolation of compiler-owned mutable types. Validate any cleanup with ordinary NullAway diagnostic tests for wildcard captures and intersection inference, including the separately inferred generic call inside a constructor lambda from #1972.

This is a follow-up investigation, not a proposed change to library-model precedence or a claim that all existing helper branches are redundant.

Dominant language
Java
Stars
4.1k
Forks
379
Avg merge
1d 2h
Merged PRs (30d)
106

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from uber/NullAway

All issues in uber/NullAway

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.