Repository navigation
Enable the test for a call on a new expression with a @Nullable type argument - #2037
Conversation
…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)
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
WalkthroughThe JSpecify generics tests add callback receiver assignment checks and enable the Suggested reviewers: Priority: ⬇️ Low Change: Other · Severity of issue fixed: Low Merge Risk: ⚪ Minimal · up to
|
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
Issue #1155 reported two false positives in JSpecify mode. A call on a
newexpression dropped the@Nullabletype argument of the class, soInner<@Nullable Object> mThing = new Inner<@Nullable Object>().identity();was reported as an assignment fromInner<Object>. Insidenew Callback<@Nullable Integer>() { ... },Callback<@Nullable Integer> self = this;was reported the same way. Both now pass: #1571 (0.13.6) fixed the call on anewexpression, and #1305 (0.12.11) fixedthisin an anonymous class. The test for the first case,GenericsTests.callWithConstructorReceiver, was still@Ignored.The
@Ignoreis removed, and the test now also assigns the same call toInner<Object>, which must be reported, so it fails whether the type argument is dropped or the call is no longer checked.GenericsTests.thisUsageInAnonymousClasspassedthisonly as an argument; it now also assignsthisto a local, in the anonymous class with a@Nullabletype argument (no error) and in the one without it (error).Each case was seen failing with its fix disabled, under
:nullaway:teston JDK 21: skipping the receiver substitution for a call on anewexpression brings back the reported warning onmThing, and skipping thethisbranch ofgetTreeTypebrings it back onself = this.Fixes #1155
Assisted-by: Claude Code (claude-opus-5-5)
🤖 Generated with Claude Code
Summary by CodeRabbit