openrewrite / rewrite-static-analysis

OpenRewrite recipes for identifying and fixing static analysis issues.
Apache License 2.0
30 stars 44 forks source link

UseCollectionInterfaces brakes on annotated types #223

Closed Bananeweizen closed 9 months ago

Bananeweizen commented 9 months ago

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

              import java.util.HashSet;
              import org.jetbrains.annotations.Nullable;

              class Test {
                  public @Nullable HashSet<@Nullable Integer> values = new HashSet<>();
              }

What is the full stack trace of any errors you encountered?

        org.openrewrite.internal.RecipeRunException: java.lang.ClassCastException: class org.openrewrite.java.tree.J$AnnotatedType cannot be cast to class org.openrewrite.java.tree.J$ParameterizedType (org.openrewrite.java.tree.J$AnnotatedType and org.openrewrite.java.tree.J$ParameterizedType are in unnamed module of loader 'app')
            at app//org.openrewrite.TreeVisitor.visit(TreeVisitor.java:329)
            at app//org.openrewrite.staticanalysis.UseCollectionInterfaces$1.visit(UseCollectionInterfaces.java:106)

Are you interested in contributing a fix to OpenRewrite?

PR is coming in a minute...

timtebeek commented 9 months ago

Must say I really appreciate the quality reports & fixes you keep churning out! Always a pleasure seeing one of your PRs pop up.