Description
Consider the following unit test:
@Test
void testOkWithTopLevelType1() {
rewriteRun( //language=java
spec -> spec.recipe(new ChangeType("java.util.Map$Entry", "java.util.List", true)),
java("""
import java.util.Map;
public class TestController {
public Map.Entry respond() {
return null;
}
}
""",
"""
import java.util.List;
public class TestController {
public List respond() {
return null;
}
}
""")
);
}
This test fails because actual results are:
public class TestController {
public java.util.List respond() {
return null;
}
}
New type name appears fully qualified. I've traced this dow to this change
The change in the J
class:
public boolean isFullyQualifiedClassReference(String className) {
if (getName().getFieldType() == null && getName().getType() instanceof JavaType.FullyQualified &&
!(getName().getType() instanceof JavaType.Unknown) &&
TypeUtils.fullyQualifiedNamesAreEqual(((JavaType.FullyQualified) getName().getType()).getFullyQualifiedName(), className)) {
return true;
} else if (!className.contains(".")) {
return false;
}
return isFullyQualifiedClassReference(this, TypeUtils.toFullyQualifiedName(className), className.length());
}
If the first if block is commented out then it works. There is some kind of mistake there it seems... I don't see where this
- the field access node content is used there... just its type is used.
Metadata
Assignees
Labels
Type
Projects
Status
Backlog
Activity