Skip to content

Fix nullability for return and parameter wildcards#1558

Merged
msridhar merged 3 commits into
masterfrom
wildcard-inference-3
May 3, 2026
Merged

Fix nullability for return and parameter wildcards#1558
msridhar merged 3 commits into
masterfrom
wildcard-inference-3

Conversation

@msridhar
Copy link
Copy Markdown
Collaborator

@msridhar msridhar commented May 1, 2026

See the new test cases. Use upper and lower bounds to reason about the nullability of accessed values of wildcard type.

Summary by CodeRabbit

  • Improvements

    • Enhanced null-checking accuracy for Java generic types with improved wildcard support
    • Better nullness analysis for method parameters, return values, and type-variable bounds in generic declarations
    • Improved handling of complex wildcard scenarios
  • Tests

    • Added test coverage for wildcard generic capture behavior across parameters, returns, and local variables

@codecov
Copy link
Copy Markdown

codecov Bot commented May 1, 2026

Codecov Report

❌ Patch coverage is 90.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.45%. Comparing base (8f7c7e5) to head (c7a52fd).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...ava/com/uber/nullaway/generics/GenericsChecks.java 90.00% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1558      +/-   ##
============================================
- Coverage     88.45%   88.45%   -0.01%     
- Complexity     2869     2878       +9     
============================================
  Files           103      103              
  Lines          9587     9603      +16     
  Branches       1930     1935       +5     
============================================
+ Hits           8480     8494      +14     
  Misses          532      532              
- Partials        575      577       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@msridhar
Copy link
Copy Markdown
Collaborator Author

msridhar commented May 1, 2026

This issue was first observed by @wilkinsona in #1528 (comment)

@msridhar
Copy link
Copy Markdown
Collaborator Author

msridhar commented May 1, 2026

@msridhar msridhar force-pushed the wildcard-inference-2 branch from fc48e50 to b3118a6 Compare May 3, 2026 01:18
@msridhar msridhar force-pushed the wildcard-inference-3 branch 2 times, most recently from 3207404 to 60a4bc1 Compare May 3, 2026 01:25
@msridhar msridhar force-pushed the wildcard-inference-2 branch from f027fde to f379612 Compare May 3, 2026 19:11
@msridhar msridhar force-pushed the wildcard-inference-3 branch from 60a4bc1 to 0803ac7 Compare May 3, 2026 19:11
Base automatically changed from wildcard-inference-2 to master May 3, 2026 19:22
@msridhar msridhar force-pushed the wildcard-inference-3 branch from 0803ac7 to c7a52fd Compare May 3, 2026 19:27
@msridhar msridhar enabled auto-merge (squash) May 3, 2026 19:27
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 3, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: f75e2c9f-f44b-4374-b923-e4ca8d04b2c4

📥 Commits

Reviewing files that changed from the base of the PR and between 8f7c7e5 and c7a52fd.

📒 Files selected for processing (2)
  • nullaway/src/main/java/com/uber/nullaway/generics/GenericsChecks.java
  • nullaway/src/test/java/com/uber/nullaway/jspecify/WildcardTests.java

Walkthrough

This PR updates GenericsChecks.java to enhance generic nullness computation by passing VisitorState to parameter and return nullness helper methods. The changes introduce support for computing nullness from wildcard generics, specifically handling the effective upper bounds in ? super ... cases and optionally following type-variable upper bounds. Four new test methods are added to WildcardTests.java to validate wildcard-capture behavior for parameters, return values, returns via type-variable upper bounds, and captured locals.

Possibly related PRs

Suggested labels

jspecify

Suggested reviewers

  • lazaroclapp
  • yuxincs
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 38.46% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically summarizes the main change: fixing nullability handling for return and parameter wildcards, which is exactly what the changeset implements.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch wildcard-inference-3

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

@msridhar msridhar merged commit 5c2780c into master May 3, 2026
14 of 22 checks passed
@msridhar msridhar deleted the wildcard-inference-3 branch May 3, 2026 19:40
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 this pull request may close these issues.

2 participants