-
Notifications
You must be signed in to change notification settings - Fork 110
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Functions.compose is not migrated, which creates a conflict with the PreferJavaUtilFunction recipe
- This issue is similar to the issue Sets.filter is not migrated, which creates a conflict with the PreferJavaUtilPredicate recipe #897. The
Functionclass from Guava is converted injava.util.function.Functioneven when it is used in aFunctions.composemethod that is not converted. As a result, the following error appears after migration:The method compose(Function<B,C>, Function<A,? extends B>) in the type Functions is not applicable for the arguments (Function<String,Integer>, Function<Object,String>).
What version of OpenRewrite are you using?
I am using
- Rewrite Maven Plugin v6.23.0
- Maven v3.9.5
- org.openrewrite.recipe:rewrite-migrate-java v3.21.0
How are you running OpenRewrite?
I used the Maven command line to launch the recipe on the Sirius Desktop repository :
mvn -U org.openrewrite.maven:rewrite-maven-plugin:6.23.0-SNAPSHOT:run -Drewrite.recipeArtifactCoordinates=org.openrewrite.recipe:rewrite-migrate-java:3.21.0-SNAPSHOT -Drewrite.activeRecipes=org.openrewrite.java.migrate.guava.NoGuava -Drewrite.exportDatatables=true -Dmaven.repo.local=./.repositoryMaven -f packaging/org.eclipse.sirius.parent/pom.xmlWhat is the smallest, simplest way to reproduce the problem?
import com.google.common.base.Function;
import com.google.common.base.Functions;
class Test {
public static void test() {
Function<Object, Integer> composed = Functions.compose(new Function<String, Integer>() {
@Override
public Integer apply(String input) {
return input.length();
}
}, new Function<Object, String>() {
@Override
public String apply(Object input) {
return input.toString();
}
});
}
}What did you expect to see?
import java.util.function.Function;
class Test {
public static void testResult() {
Function<Object, Integer> composed = new Function<String, Integer>() {
@Override
public Integer apply(String input) {
return input.length();
}
}.compose(new Function<Object, String>() {
@Override
public String apply(Object input) {
return input.toString();
}
});
}
}What did you see instead?
import com.google.common.base.Functions;
import java.util.function.Function;
class Test {
public static void test() {
Function<Object, Integer> composed = Functions.compose(new Function<String, Integer>() {
@Override
public Integer apply(String input) {
return input.length();
}
}, new Function<Object, String>() {
@Override
public String apply(Object input) {
return input.toString();
}
});
}
}Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Type
Projects
Status
Done