Repository navigation
Add regression tests for cast map reads and nullable Supplier type arguments - #2046
Conversation
…guments Three behaviors fixed by earlier changes had no test, so a regression in any of them would pass the suite. - uber#444: a null check on a cast around `Map.get`, as in `(String) m.get("k") == null ? "" : (String) m.get("k")`, did not refine `m.get("k")`, and the result was reported as `@Nullable`. uber#1997 fixed it by stripping reference casts when it computes access paths, but its tests cast a local or a map key, not the `get` result. The new `AccessPathsTests` case fails on f7b81c4, the parent of uber#1997, with `returning @nullable expression from method with @nonnull return type`. - uber#1290, method reference: `invoke(Test::returnsNull)` for `<R> void invoke(Supplier<@nullable R>)` and a `static @nullable Object returnsNull()` was reported with `Failed to infer type argument nullability` and `referenced method returns @nullable, but functional interface method Test.Supplier.get() returns @NonNull`. uber#1430 fixed it; its test passes an unbound receiver reference to a `Function`. The new case beside `supplierLambdaInference` fails with both diagnostics on 0b4156b, the parent of uber#1430. - uber#1290, dereference: inside `invoke`, dereferencing `supplier.get()` for a `java.util.function.Supplier<@nullable R>` is reported only with the JSpecify JDK models (`JSpecifyJDKModels=true`, or `JSpecifyExperimental=true`). Without them `Supplier` is unmarked and `get()` is not treated as `@Nullable`. The new `JSpecifyJDKModelsTest` case fails when its helper leaves out the models flag. The lambda case of uber#1290, `invoke(() -> null)`, is already covered by `supplierLambdaInference` (uber#1337). Fixes uber#444 Fixes uber#1290 Assisted-by: Claude Code (claude-opus-5-5)
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
WalkthroughThe pull request adds tests for null-check refinement across casted and uncast Possibly related issues
Suggested reviewers: Priority: ⬇️ Low Change: Other Merge Risk: ⚪ Minimal · up to
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2046 +/- ##
=========================================
Coverage 89.15% 89.15%
Complexity 38 38
=========================================
Files 119 119
Lines 12726 12726
Branches 2579 2579
=========================================
Hits 11346 11346
Misses 623 623
Partials 757 757 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Three behaviors fixed by earlier changes had no test, so a regression in any of them would pass the suite.
Map.get, as in(String) m.get("k") == null ? "" : (String) m.get("k"), did not refinem.get("k"), and the result was reported as@Nullable. Strip reference casts when computing access paths #1997 fixed it by stripping reference casts when it computes access paths, but its tests cast a local or a map key, not thegetresult. The newAccessPathsTestscase fails on f7b81c4, the parent of Strip reference casts when computing access paths #1997, withreturning @Nullable expression from method with @NonNull return type.invoke(Test::returnsNull)for<R> void invoke(Supplier<@Nullable R>)and astatic @Nullable Object returnsNull()was reported withFailed to infer type argument nullabilityandreferenced method returns @Nullable, but functional interface method Test.Supplier.get() returns @NonNull. JSpecify: Improve handling of method references #1430 fixed it; its test passes an unbound receiver reference to aFunction. The new case besidesupplierLambdaInferencefails with both diagnostics on 0b4156b, the parent of JSpecify: Improve handling of method references #1430.invoke, dereferencingsupplier.get()for ajava.util.function.Supplier<@Nullable R>is reported only with the JSpecify JDK models (JSpecifyJDKModels=true, orJSpecifyExperimental=true). Without themSupplieris unmarked andget()is not treated as@Nullable. The newJSpecifyJDKModelsTestcase fails when its helper leaves out the models flag.The lambda case of #1290,
invoke(() -> null), is already covered bysupplierLambdaInference(#1337).Fixes #444
Fixes #1290
Assisted-by: Claude Code (claude-opus-5-5)
🤖 Generated with Claude Code
Summary by CodeRabbit