Fix issue with passing poly expression to a function parameter with type from library model - #1614
Conversation
|
This change is part of the following stack: Change managed by git-spice. |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughIn JSpecify mode, Possibly related PRs
Suggested labels
Suggested reviewers
🚥 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❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1614 +/- ##
=========================================
Coverage 88.04% 88.05%
- Complexity 3033 3044 +11
=========================================
Files 105 105
Lines 10100 10160 +60
Branches 2051 2063 +12
=========================================
+ Hits 8893 8946 +53
- Misses 571 573 +2
- Partials 636 641 +5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
lazaroclapp
left a comment
There was a problem hiding this comment.
Minor, very much optional nits, but otherwise it LGTM!
| @NullMarked | ||
| class Test { | ||
| LambdaBox<String> test() { | ||
| return LambdaModel.map(unused -> null); |
There was a problem hiding this comment.
Maybe we have equivalent tests elsewhere, but do we want a .mapNonNull and .applyNonNull methods which demonstrate that, in the absence of a model saying otherwise, these still disallow @Nullable in those type argument locations? (Again, if there are already tests for that elsewhere, feel free to skip, just checking)
There was a problem hiding this comment.
I'm quite confident this gets tested elsewhere as part of our JSpecify tests. So I'll skip adding more such tests here.
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
test-library-models/src/test/java/com/uber/nullaway/CustomLibraryModelsTests.java (1)
612-612: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winUpdate stale expected diagnostic text
This expectation is missing the single quotes now used in dereference diagnostics, so the test can fail on message mismatch.
Suggested fix
- // BUG: Diagnostic contains: dereferenced expression value is `@Nullable` + // BUG: Diagnostic contains: dereferenced expression 'value' is `@Nullable`🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@test-library-models/src/test/java/com/uber/nullaway/CustomLibraryModelsTests.java` at line 612, The expected diagnostic text in the CustomLibraryModelsTests assertion is stale because dereference messages now wrap the expression in single quotes. Update the expectation near the existing BUG comment so it matches the current wording exactly, using the same test case and diagnostic string pattern already used in CustomLibraryModelsTests.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In
`@test-library-models/src/test/java/com/uber/nullaway/CustomLibraryModelsTests.java`:
- Line 612: The expected diagnostic text in the CustomLibraryModelsTests
assertion is stale because dereference messages now wrap the expression in
single quotes. Update the expectation near the existing BUG comment so it
matches the current wording exactly, using the same test case and diagnostic
string pattern already used in CustomLibraryModelsTests.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 6bcbf0c2-24d0-48ae-8461-dd9b81da0cc2
📒 Files selected for processing (3)
nullaway/src/main/java/com/uber/nullaway/NullAway.javanullaway/src/test/java/com/uber/nullaway/jspecify/GenericMethodLambdaOrMethodRefArgTests.javatest-library-models/src/test/java/com/uber/nullaway/CustomLibraryModelsTests.java
6947293 to
b729c46
Compare
3fbfc92 to
297a717
Compare
Consider:
Here, the
@Nullableannotation within the comment comes from a library model. Accounting for the library model, the code is legal. Before, we did not properly account for the library model, so we assumed the type of theapplyparameter wasFunction<String, String>, and reported a false positive error on the lambda body. This PR properly uses the library models so we don't get errors for cases like the above.We also do minor fixes for cases where lambdas or method references passed as parameters are enclosed in parentheses.
Summary by CodeRabbit
New Features
Bug Fixes
Tests
Documentation