-
Notifications
You must be signed in to change notification settings - Fork 37
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 forbidden-apis: 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 Error Prone: idea: check proper use of declaration-site type variance google/error-prone#3711
Metadata
Metadata
Assignees
Labels
No labels