Skip to content

Fix check for enclosing NewClassTree#1524

Merged
msridhar merged 1 commit intomasterfrom
issue-1523
Apr 13, 2026
Merged

Fix check for enclosing NewClassTree#1524
msridhar merged 1 commit intomasterfrom
issue-1523

Conversation

@msridhar
Copy link
Copy Markdown
Collaborator

@msridhar msridhar commented Apr 13, 2026

Fixes #1523

Our previous check was broken when state.getPath() pointed at a sub-tree of a constructor call within an anonymous class; the constructor call is also a NewClassTree.

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Improved handling of anonymous class type resolution in generics checking.
  • Tests

    • Added test case for constructor calls with this parameter from anonymous classes.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 13, 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: 0c81d680-f0c2-4b10-95dd-cb3b8fc77d5d

📥 Commits

Reviewing files that changed from the base of the PR and between 9c08bc5 and e0213ae.

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

Walkthrough

This PR fixes a crash in NullAway when handling constructor calls with this from within anonymous inner classes. The fix updates the getTypeForSymbol method in GenericsChecks.java to use upward traversal of the TreePath to locate the correct anonymous NewClassTree, replacing a direct lookup approach that failed in nested scenarios. A corresponding test case is added to verify the fix handles the previously crashing code pattern.

Possibly related PRs

Suggested labels

jspecify

Suggested reviewers

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

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.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 accurately describes the main code change: fixing the check for enclosing NewClassTree in GenericsChecks, which directly addresses the crash reported in issue #1523.
Linked Issues check ✅ Passed The PR successfully resolves issue #1523 by replacing the broken enclosing NewClassTree check with an upward TreePath traversal that correctly handles constructor calls nested inside anonymous classes.
Out of Scope Changes check ✅ Passed All changes are directly in scope: GenericsChecks.java fixes the broken enclosing NewClassTree detection logic, and GenericsTests.java adds a test case for the exact scenario from issue #1523.

✏️ 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-1523

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
Copy link
Copy Markdown

codecov Bot commented Apr 13, 2026

Codecov Report

❌ Patch coverage is 71.42857% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.48%. Comparing base (9c08bc5) to head (e0213ae).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...ava/com/uber/nullaway/generics/GenericsChecks.java 71.42% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1524      +/-   ##
============================================
- Coverage     88.48%   88.48%   -0.01%     
- Complexity     2841     2843       +2     
============================================
  Files           103      103              
  Lines          9487     9489       +2     
  Branches       1902     1905       +3     
============================================
+ Hits           8395     8396       +1     
  Misses          531      531              
- Partials        561      562       +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.

@seemantasaha seemantasaha self-requested a review April 13, 2026 19:48
@msridhar msridhar merged commit a6855fd into master Apr 13, 2026
10 of 12 checks passed
@msridhar msridhar deleted the issue-1523 branch April 13, 2026 19:51
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.

NullAway crash with 0.13.2 wrt Constructors in inner classes

2 participants