-
Notifications
You must be signed in to change notification settings - Fork 496
Closed
Labels
recipeRequested RecipeRequested Recipe
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 OpenRewrite: Function, Predicate, BiFunction, Consumer, Supplier, and so on.
Here is a recent case:
WDYT?
Corner cases:
- https://github.com/JetBrains/intellij-community/blob/cd82cab9aff47787e684b4a58be902d1b917f264/plugins/InspectionGadgets/src/com/siyeh/ig/style/BoundedWildcardInspection.java
- https://youtrack.jetbrains.com/issue/IDEA-235069/False-positive-in-Can-use-bounded-wildcard
- https://github.com/JetBrains/intellij-community/blob/cd82cab9aff47787e684b4a58be902d1b917f264/plugins/InspectionGadgets/src/com/siyeh/ig/style/VarianceUtil.java#L125-L133
See also:
- Discussion in Error Prone: idea: check proper use of declaration-site type variance google/error-prone#3711
- Discussion in forbidden-apis: idea: check proper use of declaration-site type variance policeman-tools/forbidden-apis#216
Metadata
Metadata
Assignees
Labels
recipeRequested RecipeRequested Recipe
Type
Projects
Status
Done