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.RemoveRedundantTypeCast fails to consider generics correctly #353

Open
blipper opened this issue Oct 3, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@blipper
Copy link
Contributor

blipper commented Oct 3, 2024

What is the smallest, simplest way to reproduce the problem?

class A {
    void foo() {
        var a = new HashMap<String, String>();
         Optional.of((Map<String, Object>)a)
                .filter(Predicate.not(Map::isEmpty));
    }
}

What did you expect to see?

class A {
    void foo() {
        var a = new HashMap<String, String>();
         Optional.of((Map<String, Object>)a)
                .filter(Predicate.not(Map::isEmpty));
    }
}

What did you see instead?

class A {
    void foo() {
        var a = new HashMap<String, String>();
         Optional.of(a)
                .filter(Predicate.not(Map::isEmpty));
    }
}

This fails to compile because generics require an exact map on type so Map != HashMap.

@blipper blipper added the bug Something isn't working label Oct 3, 2024
@timtebeek timtebeek changed the title rg.openrewrite.staticanalysis.RemoveRedundantTypeCast fails to consider generics correctly org.openrewrite.staticanalysis.RemoveRedundantTypeCast fails to consider generics correctly Oct 6, 2024
@timtebeek timtebeek moved this to Backlog in OpenRewrite Oct 6, 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
Projects
Status: Backlog
Development

No branches or pull requests

1 participant