Properly use declaration-site type variance

MSAL

Java requires use-site type variance, so a Function<IN, OUT> method parameter should rather be Function<? super IN, ? extends OUT>. It is easy to miss that ? super and ? extends are absent, so this recipe adds them where that improves the situation.

org.openrewrite.staticanalysis.DeclarationSiteTypeVariance

Required

A list of well-known classes that have in/out type variance. Separate values with commas.

Optional

A list of bounds that should not receive explicit variance. Globs supported. Separate values with commas.

excludeFinalClassesBoolean

If true, do not add ? extends variance to final classes. ? super variance will be added regardless of finality.

mod run . --recipe=org.openrewrite.staticanalysis.DeclarationSiteTypeVariance \ -P variantTypes='java.util.function.Function<IN, OUT>'

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.