RemoveUnusedImport bug
HelloDhero opened this issue · comments
package com.a.b;
public interface Abc {
public static interface Def {
......
}
public static interface Xyz {
......
}
}
package com.a.c;
import com.a.b.Abc;
import com.a.b.Abc.*;
public class Ac extents Xxx<Xyz> {
public void aaa(Abc.Xyz xyz){
}
}
when use "RemoveUnusedImport" it cause cannot compile
Hi @HelloDhero ; thanks for the report. I've turned the above into a runnable test; the only thing missing from this test is the Xxx
type that you left out. Would you mind updating the below test?
@Test
@Issue("https://github.com/openrewrite/rewrite/issues/4315")
void nestedInterfaces() {
//language=java
rewriteRun(
java(
"""
package com.a.b;
public interface Abc {
public static interface Def {
}
public static interface Xyz {
}
}
"""
),
java(
"""
package com.a.c;
import com.a.b.Abc;
import com.a.b.Abc.*;
public class Ac extends Xxx<Xyz> {
public void aaa(Abc.Xyz xyz){
}
}
"""
)
);
}
And am I right in deducing you expected no change at all? Otherwise it would help to have a description of what you expected, as per our issue template.
Use the following code
package com.test.a;
public interface Class001 {
public interface InnerInf {
}
}
package com.test;
import com.test.a.Class001.*;
public class ForUnsedImport implements InnerInf {
public static void main(String[] args) {
System.err.println(InnerInf.class);
}
}
Right now it's a bit unclear to me what you're seeing or expecting. It would really help if you followed this template:
https://github.com/openrewrite/.github/blob/main/.github/ISSUE_TEMPLATE/bug_report.md
That way we have a complete understanding of what you're after. Even better in the form of a runnable test as the example I showed above.