Skip to content

Enable the test for a call on a new expression with a @Nullable type argument - #2037

Merged
msridhar merged 1 commit into
uber:masterfrom
vlsi:claude/issue-1155-unignore-test
Oct 24, 2026
Merged

msridhar merged 1 commit into
uber:masterfrom
vlsi:claude/issue-1155-unignore-test

Conversation

@vlsi

@vlsi vlsi commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

Issue #1155 reported two false positives in JSpecify mode. A call on a new expression dropped the @Nullable type argument of the class, so Inner<@Nullable Object> mThing = new Inner<@Nullable Object>().identity(); was reported as an assignment from Inner<Object>. Inside new Callback<@Nullable Integer>() { ... }, Callback<@Nullable Integer> self = this; was reported the same way. Both now pass: #1571 (0.13.6) fixed the call on a new expression, and #1305 (0.12.11) fixed this in an anonymous class. The test for the first case, GenericsTests.callWithConstructorReceiver, was still @Ignored.

The @Ignore is removed, and the test now also assigns the same call to Inner<Object>, which must be reported, so it fails whether the type argument is dropped or the call is no longer checked. GenericsTests.thisUsageInAnonymousClass passed this only as an argument; it now also assigns this to a local, in the anonymous class with a @Nullable type argument (no error) and in the one without it (error).

Each case was seen failing with its fix disabled, under :nullaway:test on JDK 21: skipping the receiver substitution for a call on a new expression brings back the reported warning on mThing, and skipping the this branch of getTreeType brings it back on self = this.

Fixes #1155

Assisted-by: Claude Code (claude-opus-5-5)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Expanded coverage for generic nullability checks, including constructor receiver calls and assignments within anonymous-class callbacks.
    • Added checks for both accepted and incompatible assignments involving nullable callback types.

…argument

Issue uber#1155 reported two false positives in JSpecify mode. A call on a `new` expression dropped the `@Nullable` type argument of the class, so `Inner<@nullable Object> mThing = new Inner<@nullable Object>().identity();` was reported as an assignment from `Inner<Object>`. Inside `new Callback<@nullable Integer>() { ... }`, `Callback<@nullable Integer> self = this;` was reported the same way. Both now pass: uber#1571 (0.13.6) fixed the call on a `new` expression, and uber#1305 (0.12.11) fixed `this` in an anonymous class. The test for the first case, `GenericsTests.callWithConstructorReceiver`, was still `@Ignore`d.

The `@Ignore` is removed, and the test now also assigns the same call to `Inner<Object>`, which must be reported, so it fails whether the type argument is dropped or the call is no longer checked. `GenericsTests.thisUsageInAnonymousClass` passed `this` only as an argument; it now also assigns `this` to a local, in the anonymous class with a `@Nullable` type argument (no error) and in the one without it (error).

Each case was seen failing with its fix disabled, under `:nullaway:test` on JDK 21: skipping the receiver substitution for a call on a `new` expression brings back the reported warning on `mThing`, and skipping the `this` branch of `getTreeType` brings it back on `self = this`.

Fixes uber#1155

Assisted-by: Claude Code (claude-opus-5-5)
@coderabbitai

coderabbitai Bot commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
📥 Commits

Reviewing files that changed from the base of the PR and between 7f85800 and 02f374b.

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

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 4 remain after this review.

Walkthrough

The JSpecify generics tests add callback receiver assignment checks and enable the callWithConstructorReceiver test. The enabled test now expects an incompatible-type diagnostic for assigning the result of identity() to Inner<Object>.

Suggested reviewers: msridhar

Priority: ⬇️ Low

Change: Other · Severity of issue fixed: Low

Merge Risk: ⚪ Minimal · up to 02f37

No actionable merge-blocking risk is identified.

Pre-merge checks: Passed 4 · Failed 1

Failed 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%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: enabling a test for a call on a new expression with a nullable type argument.
Description check Passed The description directly explains the test changes, the related false positives, the expected diagnostics, and the linked issue.
Linked Issues check Passed Issue #1155 requires coverage for new Inner<@Nullable Object>().identity() so the nullable type argument is preserved. The PR removes the @Ignore from GenericsTests.callWithConstructorReceiver a…
Out of Scope Changes check Passed The PR changes only GenericsTests.java. The changes remove an obsolete ignore and add regression assertions for the constructor-receiver and anonymous-class this cases described in the PR and rela…
Full details: Linked Issues check

Explanation

Issue #1155 requires coverage for new Inner&lt;@Nullable Object&gt;().identity() so the nullable type argument is preserved. The PR removes the @Ignore from GenericsTests.callWithConstructorReceiver and adds an expected diagnostic for assignment to Inner&lt;Object&gt;. The nullable assignment remains without a diagnostic. The PR also adds coverage for the related anonymous-class this type case.

Full details: Out of Scope Changes check

Explanation

The PR changes only GenericsTests.java. The changes remove an obsolete ignore and add regression assertions for the constructor-receiver and anonymous-class this cases described in the PR and related to issue #1155. No unrelated production or test changes are present in the reviewed diff.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@codecov

codecov Bot commented Oct 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.15%. Comparing base (ef0ddbd) to head (02f374b).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #2037      +/-   ##
============================================
+ Coverage     89.13%   89.15%   +0.01%     
  Complexity       38       38              
============================================
  Files           119      119              
  Lines         12707    12721      +14     
  Branches       2580     2578       -2     
============================================
+ Hits          11327    11341      +14     
  Misses          623      623              
  Partials        757      757              

☔ View full report in Codecov by Harness.
📢 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 added this pull request to the merge queue Oct 24, 2026
Merged via the queue into uber:master with commit c664e11 Oct 24, 2026
20 checks passed
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.

Nullness of generics is lost for "new Foo<@Nullable Object>().bar()"

2 participants