Open
Description
consider a case like this:
@SuppressWarnings("DataFlowIssue")
@ExpectedToFail("fails because there's a reference change but no content diff but that's the point; would need to adjust RewriteTest")
@Test
void changeTypeAttributionImplicitUsage() {
rewriteRun(
spec -> spec.recipe(new ChangeType("java.util.List", "java.util.ArrayList", false)),
groovy(
"""
import java.util.Collections
class Test {
int zero = Collections.emptyList().size()
}
""",
spec -> spec.afterRecipe(cu -> {
J.VariableDeclarations varDecl = (J.VariableDeclarations) cu.getClasses().get(0).getBody().getStatements().get(0);
J.MethodInvocation sizeMi = (J.MethodInvocation) varDecl.getVariables().get(0).getInitializer();
assertThat(TypeUtils.isOfClassType(sizeMi.getMethodType().getDeclaringType(),
"java.util.ArrayList")).isTrue();
J.MethodInvocation emptyListMi = (J.MethodInvocation) sizeMi.getSelect();
assertThat(TypeUtils.isOfClassType(emptyListMi.getMethodType().getReturnType(),
"java.util.ArrayList")).isTrue();
})
)
);
}
The recipe makes changes to type attribution in the tree, but, that's not a "visible" change, so the rewriteRun
logic auto-fails the test (due to the condition which checks for reference changes without content changes). It would be nice to have some mechanism to run tests like this.
Metadata
Assignees
Labels
Type
Projects
Status
Backlog
Activity