Repository navigation
Add support for filtering null objects from streams - #1597
Conversation
|
This change is part of the following stack: Change managed by git-spice. |
WalkthroughAdds an optional MethodInvocationTree parameter to Handler.onOverrideMethodType and a new isSingleArgNullImpliesFalseMethod hook, propagates invocation-site context through GenericsChecks call sites, wires the StreamNullabilityPropagator into handler initialization, implements onOverrideMethodType in that propagator to refine Stream element nullability for null-rejecting filters, and adds tests exercising Objects::nonNull, custom predicates, and Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #1597 +/- ##
============================================
- Coverage 88.12% 87.99% -0.13%
- Complexity 3001 3022 +21
============================================
Files 105 105
Lines 9952 10021 +69
Branches 2021 2041 +20
============================================
+ Hits 8770 8818 +48
- Misses 565 572 +7
- Partials 617 631 +14 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
lazaroclapp
left a comment
There was a problem hiding this comment.
Looks entirely good to me :)
Fixes #1578
Fixes #1594
Now, if we have a
Stream<@Nullable Foo>sand the code invokess.filter(Objects::nonNull), the result type isStream<Foo>. This works for any method that has an appropriate library model or any method annotated@Contract(null -> false).This PR does not handle lambdas, e.g.,
s.filter(x -> x != null); we can add such support in a follow-up if it comes up often.Main support is in
StreamNullabilityPropagator.onOverrideMethodType. To identify filtering methods, we add a newHandlermethodisSingleArgNullImpliesFalseMethodand implement inLibraryModelsHandlerandContractHandler.Summary by CodeRabbit
New Features
Tests