What version of OpenRewrite are you using?
rewrite 8.75.2
What is the smallest, simplest way to reproduce the problem?
Add this test case in ChangeMethodInvocationReturnTypeTest
@Test
void replaceVariableAssignmentWithGenericReturnType() {
rewriteRun(
spec -> spec.recipe(new ChangeMethodInvocationReturnType("bar.Bar bar()", "java.util.Set<java.lang.String>"))
.parser(JavaParser.fromJavaVersion()
//language=java
.dependsOn(
"""
package bar;
import java.util.List;
public class Bar {
public static List<String> bar() {
return null;
}
}
"""
)
),
//language=java
java(
"""
import bar.Bar;
import java.util.List;
class Foo {
void foo() {
List<String> one = Bar.bar();
}
}
""",
"""
import bar.Bar;
import java.util.Set;
class Foo {
void foo() {
Set<String> one = Bar.bar();
}
}
"""
)
);
}
Result:

What version of OpenRewrite are you using?
rewrite 8.75.2
What is the smallest, simplest way to reproduce the problem?
Add this test case in
ChangeMethodInvocationReturnTypeTestResult: