Substitute inferred @NonNull types for generic method inference#1445
Conversation
@NonNull types for generic method inference
| @Override | ||
| public String visitErrorType(Type.ErrorType t, @Nullable Void unused) { | ||
| // this arises for our synthetic @Nullable and @NonNull annotations; we just return the simple | ||
| // name | ||
| return t.tsym.getSimpleName().toString(); | ||
| } |
There was a problem hiding this comment.
Drive-by fix to make printed errors more readable, by printing e.g. @NonNull instead of @nullaway.synthetic.NonNull
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1445 +/- ##
=========================================
Coverage 88.40% 88.40%
- Complexity 2711 2712 +1
=========================================
Files 99 99
Lines 9004 9007 +3
Branches 1799 1799
=========================================
+ Hits 7960 7963 +3
Misses 517 517
Partials 527 527 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
WalkthroughAdds an override to GenericTypePrettyPrintingVisitor to print Type.ErrorType as the simple symbol name, and changes TypeSubstitutionUtils.substituteInferredNullabilityForTypeVariables to substitute inferred nullability for all matching type variables (emitting synthetic nullable or non-null annotations based on the inferred value). Tests were updated for expected diagnostic messages and two new tests (issue1444) were added covering contract/nonnull behavior. Possibly related PRs
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
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 |
Fixes #1444
In certain cases, like the test from #1444 added here,
javacadds a@Nullableannotation to a type incorrectly as part of its inference. Here, for a call from the test:javacs inferred type for the return of thenotNullcall matches the inferred parameter type exactly,@Nullable Stream<...>. But, when applying JSpecify rules, the return cannot be@Nullable. To fix this, add inferred@NonNullqualifiers along with@Nullablewhen doing a substitution inside a type.Summary by CodeRabbit
Bug Fixes
Tests
✏️ Tip: You can customize this high-level summary in your review settings.