Skip to content

Add regression tests for cast map reads and nullable Supplier type arguments - #2046

Merged
msridhar merged 1 commit into
uber:masterfrom
vlsi:add-regression-tests-444-1290
Oct 24, 2026
Merged

msridhar merged 1 commit into
uber:masterfrom
vlsi:add-regression-tests-444-1290

Conversation

@vlsi

@vlsi vlsi commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

Three behaviors fixed by earlier changes had no test, so a regression in any of them would pass the suite.

The lambda case of #1290, invoke(() -> null), is already covered by supplierLambdaInference (#1337).

Fixes #444
Fixes #1290

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

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Expanded coverage for nullability analysis involving casted map lookups, including checks that distinguish between matching and different keys.
    • Added JSpecify coverage for nullable values returned from suppliers and for nullability inferred through method references.
    • Added checks for the expected diagnostics when nullable values are dereferenced, alongside cases where no diagnostic is expected.

…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)
@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 e91ea4b and 67273c3.

📒 Files selected for processing: 3
  • nullaway/src/test/java/com/uber/nullaway/AccessPathsTests.java
  • nullaway/src/test/java/com/uber/nullaway/JSpecifyJDKModelsTest.java
  • nullaway/src/test/java/com/uber/nullaway/jspecify/GenericMethodLambdaOrMethodRefArgTests.java

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

Walkthrough

The pull request adds tests for null-check refinement across casted and uncast Map.get calls. It also adds JSpecify tests for nullable Supplier.get() results and generic inference when passing a method reference to generic methods.

Possibly related issues

  • uber/NullAway issue 444 — The map lookup test covers casted Map.get null-check refinement described in the issue.
  • uber/NullAway issue 1290 — The method-reference test adds coverage for the generic Supplier<@Nullable R> inference contract described in the issue.

Suggested reviewers: msridhar

Priority: ⬇️ Low

Change: Other

Merge Risk: ⚪ Minimal · up to 67273

The added regression tests cover the stated behaviors, with no identified issue to resolve before merge. Normal checks remain appropriate.

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 9 functions across 3 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 names the two main areas of the change: regression tests for cast Map.get reads and for nullable Supplier type arguments. The changeset adds tests for the cast-around-Map.get null check, the…
Description check Passed The description is specific and on-topic. It explains the three regression behaviors, names the test files and cases that cover them, states which parent commits fail, and links issues #444 and #1290.…
Linked Issues check Passed The changes add regression coverage for both directly linked issues. For #444, nullCheckOfCastMapGetRefinesTheSameGet checks that a casted Map.get("k") null check refines the same map read in tern…
Out of Scope Changes check Passed All changes are focused test additions in AccessPathsTests, JSpecifyJDKModelsTest, and GenericMethodLambdaOrMethodRefArgTests. Each test covers the nullability and generic-inference behavior des…
Full details: Title check

Explanation

The title names the two main areas of the change: regression tests for cast Map.get reads and for nullable Supplier type arguments. The changeset adds tests for the cast-around-Map.get null check, the Supplier<@Nullable R> method-reference inference, and the JSpecify JDK models dereference case. The title omits the third area's specifics but covers the primary intent.

Full details: Description check

Explanation

The description is specific and on-topic. It explains the three regression behaviors, names the test files and cases that cover them, states which parent commits fail, and links issues #444 and #1290. This matches the changed test files in AccessPathsTests, JSpecifyJDKModelsTest, and GenericMethodLambdaOrMethodRefArgTests.

Full details: Linked Issues check

Explanation

The changes add regression coverage for both directly linked issues. For #444, nullCheckOfCastMapGetRefinesTheSameGet checks that a casted Map.get("k") null check refines the same map read in ternary and if branches, while a different key remains nullable. For #1290, the existing supplierLambdaInference test covers the linked lambda requirement, and this pull request adds supplierMethodRefInference for a nullable method reference. supplierGetWithNullableTypeArgumentIsNullable also verifies nullable Supplier.get() behavior with JSpecify JDK models. The diff contains no missing coding requirement from the linked issues.

Full details: Out of Scope Changes check

Explanation

All changes are focused test additions in AccessPathsTests, JSpecifyJDKModelsTest, and GenericMethodLambdaOrMethodRefArgTests. Each test covers the nullability and generic-inference behavior described in the pull request and linked issues. 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 (e91ea4b) to head (67273c3).

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.
📢 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 b76829a 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.

Better support lambda parameters in generic method inference Handling interactions between casts and our map handling in dataflow

2 participants