Skip to content

Handle subtype checking for wildcard super bounds - #1547

Merged
msridhar merged 7 commits into
masterfrom
wildcards-2
Apr 26, 2026
Merged

msridhar merged 7 commits into
masterfrom
wildcards-2

Conversation

@msridhar

@msridhar msridhar commented Apr 25, 2026 •

Copy link
Copy Markdown
Collaborator

Add one more case of containment checking, handling super-bounded wildcards (? super T). Also, update a comment for another case, which we'll need to handle alongside inference support.

Summary by CodeRabbit

  • Bug Fixes

    • Significantly improved type nullability checking for complex generic type parameter patterns, enabling more precise detection and reporting of type assignment incompatibilities in your codebase.
  • Tests

    • Added comprehensive test coverage for various wildcard generic type parameter edge cases and scenarios.
    • Updated test expectations to align with the improved type compatibility diagnostics.

@msridhar
msridhar marked this pull request as ready for review April 25, 2026 18:54
@coderabbitai

coderabbitai Bot commented Apr 25, 2026 •

Copy link
Copy Markdown
Contributor

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: 5b135aec-25fb-4ad7-8253-09581cddaaa3

📥 Commits

Reviewing files that changed from the base of the PR and between e90a5d4 and 7baaaed.

📒 Files selected for processing (1)
  • nullaway/src/test/java/com/uber/nullaway/jspecify/WildcardTests.java

Walkthrough

Adds explicit handling for formal wildcard type arguments of the form ? super S in CheckIdenticalNullabilityVisitor. BoundKind.SUPER is routed to a new helper that computes containment by checking S is a nullability-aware subtype of the actual type argument (covering concrete actuals T and wildcard actuals ? super T and permissively accepting unexpected wildcard shapes). The prior early-return for non-wildcard-formal / wildcard-actual remains unchanged. A unit test exercising ? super semantics was added and one test expectation for nested wildcards was updated.

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 42.86% 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 accurately and concisely describes the primary change: adding support for wildcard super bounds in subtype checking within the NullAway type checker.
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 wildcards-2

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

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@nullaway/src/test/java/com/uber/nullaway/jspecify/WildcardTests.java`:
- Around line 232-260: Test name wildcardSuperFormalNoInference contains a stray
numeric suffix on a local variable: rename nonnullSuperLocal2 to
nonnullSuperLocal inside the test method (class WildcardTests, method
wildcardSuperFormalNoInference) and update any references in that method so the
variable name is consistent and clearer.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: df0ff97d-4004-4e87-b9fc-3b768b5c25f0

📥 Commits

Reviewing files that changed from the base of the PR and between 1cee45c and f30b07a.

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

@codecov

codecov Bot commented Apr 25, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.49%. Comparing base (1cee45c) to head (7baaaed).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...way/generics/CheckIdenticalNullabilityVisitor.java 80.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1547      +/-   ##
============================================
- Coverage     88.50%   88.49%   -0.02%     
- Complexity     2857     2859       +2     
============================================
  Files           103      103              
  Lines          9517     9525       +8     
  Branches       1912     1914       +2     
============================================
+ Hits           8423     8429       +6     
- Misses          528      529       +1     
- Partials        566      567       +1     

☔ 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@nullaway/src/test/java/com/uber/nullaway/jspecify/WildcardTests.java`:
- Around line 232-260: The test uses loose diagnostic markers for two expected
failures; in WildcardTests.wildcardSuperFormalNoInference update the two "//
BUG: Diagnostic contains: incompatible types:" comments for the failing
assignments to nullableSuperLocal3 and nullableSuperFromNonnullSuper to the
exact converted-types text used elsewhere in the test suite (i.e., include the
full "incompatible types: ... cannot be converted to ..." message with the
concrete converted type strings) so the assertions precisely match the
diagnostic output instead of a generic contains check.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 96e32a29-9ac2-4beb-9db5-783c5828d887

📥 Commits

Reviewing files that changed from the base of the PR and between 74a3d37 and e90a5d4.

📒 Files selected for processing (1)
  • nullaway/src/test/java/com/uber/nullaway/jspecify/WildcardTests.java

@lazaroclapp lazaroclapp left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@msridhar
msridhar merged commit f44379a into master Apr 26, 2026
10 of 12 checks passed
@msridhar
msridhar deleted the wildcards-2 branch April 26, 2026 19:33
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