Skip to content

Fix crash with captured array types - #1508

Merged
msridhar merged 4 commits into
masterfrom
issue-1503
Apr 8, 2026
Merged

msridhar merged 4 commits into
masterfrom
issue-1503

Conversation

@msridhar

@msridhar msridhar commented Apr 3, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1503

Summary by CodeRabbit

  • Bug Fixes

    • Improved handling of captured/wildcard array types during generic nullability checks to prevent incorrect assumptions and avoid crashes in expressions that mix arrays and generics.
  • Tests

    • Added a regression test exercising captured array types in ternary expressions to ensure the fix prevents crashes and maintains correct nullability behavior.

@coderabbitai

coderabbitai Bot commented Apr 3, 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: de2b2e12-5cee-4d27-987e-a2f8dbe831f0

📥 Commits

Reviewing files that changed from the base of the PR and between 1aa5de6 and 47189eb.

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

Walkthrough

Updated CheckIdenticalNullabilityVisitor.visitArrayType to avoid casting rhsType to Type.ArrayType; it now checks whether rhsType is an array and returns true early for non-array rhs (e.g., captured types). If rhs is an array, the component type is extracted from that matched array type and used for the existing nullability/component comparisons. Added a new JUnit test issue1503CapturedArrayTypeInTernary exercising a captured-array type in a ternary expression to ensure no crash.

Possibly related PRs

Suggested labels

run-benchmarks

Suggested reviewers

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

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% 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 'Fix crash with captured array types' directly and clearly summarizes the main change: fixing a ClassCastException crash that occurs when encountering captured array types in NullAway's type checking logic.
Linked Issues check ✅ Passed The PR successfully addresses issue #1503 by preventing the ClassCastException in CheckIdenticalNullabilityVisitor.visitArrayType through pattern matching to check if rhsType is an ArrayType before casting, and returns true immediately when it isn't.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the crash: the fix modifies the problematic visitArrayType method, and the test validates the fix covers the reported scenario with no unrelated alterations.

✏️ 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 issue-1503

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.

@codecov

codecov Bot commented Apr 3, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.47%. Comparing base (498636f) to head (47189eb).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #1508   +/-   ##
=========================================
  Coverage     88.47%   88.47%           
- Complexity     2837     2838    +1     
=========================================
  Files           101      101           
  Lines          9460     9461    +1     
  Branches       1895     1896    +1     
=========================================
+ Hits           8370     8371    +1     
  Misses          529      529           
  Partials        561      561           

☔ 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
msridhar requested a review from lazaroclapp April 3, 2026 21:00
@msridhar
msridhar enabled auto-merge (squash) April 8, 2026 19:16
@msridhar
msridhar merged commit 97707ed into master Apr 8, 2026
6 checks passed
@msridhar
msridhar deleted the issue-1503 branch April 8, 2026 19:26
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.

ClassCastException in NullAway

2 participants