Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

org.openrewrite.staticanalysis.UseCollectionInterfaces does not properly remove import #357

Open
blipper opened this issue Oct 11, 2024 · 1 comment
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@blipper
Copy link
Contributor

blipper commented Oct 11, 2024

import java.util.concurrent.ConcurrentLinkedQueue;
class A {
    private final ConcurrentLinkedQueue<String> widgetDataList;
    public foo() {
      widgetDataList.add("TEST");
    }
}

What did you expect to see?

import java.util.Queue;
class A {
    private final Queue<String> widgetDataList;
    public foo() {
      widgetDataList.add("TEST");
    }

}

What did you see instead?

import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.Queue;
class A {
    private final Queue<String> widgetDataList;
    public foo() {
      widgetDataList.add("TEST");
    }

}

https://github.com/openrewrite/rewrite-static-analysis/blob/main/src/main/java/org/openrewrite/staticanalysis/UseCollectionInterfaces.java#L166 has the removal but is doesn't sem to work?

Are you interested in contributing a fix to OpenRewrite?

@blipper blipper added the bug Something isn't working label Oct 11, 2024
@timtebeek timtebeek moved this to Backlog in OpenRewrite Oct 11, 2024
@timtebeek
Copy link
Contributor

Thanks for the clear example! I suspect there's a dangling type reference on the field, identifier or method that still refers to the old type, and thus blocks removal of the import. Might be easy to spot if the above is converted into a runnable test of a draft PR. Once we clear out any remaining references the import should be dropped.

@timtebeek timtebeek added the good first issue Good for newcomers label Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
Status: Backlog
Development

No branches or pull requests

2 participants