rewrite
rewrite copied to clipboard
Static import is removed and leaves ambiguous reference behind
What's changed?
RemoveUnusedImports recipe should not remove static import when this leaves an ambiguous reference behind
What's your motivation?
Anything in particular you'd like reviewers to focus on?
Anyone you would like to review specifically?
@timtebeek
Have you considered any alternatives or workarounds?
Any additional context
Checklist
- [x] I've added unit tests to cover both positive and negative cases
- [x] I've read and applied the recipe conventions and best practices
- [x] I've used the IntelliJ IDEA auto-formatter on affected files
Capturing the failure here:
expected:
package org.test;
import static org.a.ABC.*;
import static org.b.DEF.*;
import static org.a.ABC.ALL;
public class Test {
private String abc = ALL;
private String a = A;
private String b = B;
private String c = C;
private String d = D;
private String e = E;
private String f = F;
}
but was:
package org.test;
import static org.a.ABC.*;
import static org.b.DEF.*;
public class Test {
private String abc = ALL;
private String a = A;
private String b = B;
private String c = C;
private String d = D;
private String e = E;
private String f = F;
}
This indeed seems to match the case reported, thanks! Lets look at what we can do to fix the issue.
Perhaps good to briefly evaluate if we can fold in a fix for this issue as well
- https://github.com/openrewrite/rewrite/issues/4452