idea: check proper use of declaration-site type variance
- Dominant language
- Java
- Stars
- 7.2k
- Forks
- 820
- Avg merge
- 5h 9m
- Merged PRs (30d)
- 50
Description
See:
* https://github.com/jspecify/jspecify/issues/72
Currently, Java requires use-site type variance, so if someone has `Function` method parameter, it should rather be `Function`.
Unfortunately, it is not easy to notice that `? super` and `? extends` is missing, so it would be nice if there was a tool that could detect missing variance and suggest adding it.
The list of well-known classes could be hard-coded within ErrorProne: `Function`, `Predicate`, `BiFunction`, `Consumer`, `Supplier`, and so on.
Here a recent case:
* https://github.com/assertj/assertj/pull/2905
WDYT?
See also:
* Discussion in OpenRewrite: https://github.com/openrewrite/rewrite/issues/2621
* Discussion in forbidden-apis: https://github.com/policeman-tools/forbidden-apis/issues/216
/cc @Stephan202
Contributor guide
Assessment
This issue has not been assessed yet.