Repository navigation
Cover anonymous class type arguments and modeled call-site returns - #1777
Conversation
uber#1746 reported that an anonymous class dropped the @nullable on its supertype's type argument, and uber#1722 fixed it. The test that PR added covers the interface form with one level of nesting, so the diamond form and an array element are still unpinned. uber#1722 also changed how astubx signatures are normalized, which lets 36 entries of jspecify-jdk.astubx match for the first time. Those entries feed hasNullableReturn at every call site, and callSite discarded the result of map.compute, so only the override direction was pinned. Every case here fails at 70da029, the commit before uber#1722. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 8 included reviews per hour; 6 remain after this review. WalkthroughExpanded JSpecify test coverage in two areas. The JDK model test now checks that the result of Suggested reviewers: Merge Risk: ⚪ Minimal · up to This change expands regression coverage for existing nullability behavior without modifying shipped code or runtime behavior; no actionable merge-blocking risk remains after normal checks and review. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1777 +/- ##
=========================================
Coverage 87.65% 87.65%
Complexity 3291 3291
=========================================
Files 109 109
Lines 11084 11084
Branches 2247 2247
=========================================
Hits 9716 9716
Misses 641 641
Partials 727 727 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Follow-up tests for #1746, which #1722 fixed. Offered per #1746 (comment)
Why
overrideExplicitlyTypedAnonymousClassWithNestedGenericTypes, added by #1722, covers an anonymous class that implements an interface at@Nullable Stringand overridesList<T>. The diamond form and an array element take paths that test does not reach, and #1746 reported both as false positives.#1722 also stopped
nullableReturns()from stripping whitespace out of astubx signatures, which lets 36 entries ofjspecify-jdk.astubxmatch for the first time — every one of them differing only by a space inside a wildcard bound such as? super K. Those entries feedhasNullableReturnat every call site, not only at override checks, andmapComputeOverrideUsesJSpecifyModeldiscarded the result ofmap.compute(...), so nothing pinned the call-site direction.What
Two new tests in
GenericsTests: a diamond anonymous class whose overrides wrap the type variable inList<T>, and an anonymous class in both the explicit and the diamond form whose overrides wrap it in an array.mapComputeOverrideUsesJSpecifyModelnow also dereferences the result ofmap.compute(...). The bare call stays: an unmarked line asserts that no diagnostic fires there, which is how the existing test pins that aBiFunction<String, @Nullable String, @Nullable String>argument is accepted. A// BUG:marker on that line would have consumed any other diagnostic it produced.Optional.orElseGetis the other way to pin the call-site direction, and this change leaves it alone.JSpecifyLibraryModelsTests.optionalOrElseGetpasses today, butLibraryModelsHandlerstill carries the hand-written model for that method commented out under #1616, so removing the@Ignoreis a call for a maintainer rather than for this pull request.How to verify
Every assertion here fails at 70da029, the commit before #1722. The two array blocks needed checking one marker at a time, because the harness stops at the first unmarked line that carries an error.
Summary by CodeRabbit
Map.computeresults, correctly identifying values that may be null.@Nullableannotations when analyzing anonymous classes with nested generic types, diamond syntax, and arrays of type variables.