-
Notifications
You must be signed in to change notification settings - Fork 777
Open
Description
See:
Currently, Java requires use-site type variance, so if someone has Function<IN, OUT> method parameter, it should rather be Function<? super IN, ? extends OUT>.
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:
WDYT?
See also:
- Discussion in OpenRewrite: idea: check and fix use of declaration-site type variance openrewrite/rewrite#2621
- Discussion in forbidden-apis: idea: check proper use of declaration-site type variance policeman-tools/forbidden-apis#216
/cc @Stephan202
Stephan202
Metadata
Metadata
Assignees
Labels
No labels