We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
The issue reproduces with the current snapshot.
MissingOverrideAnnotation converts 2d array to 1d one, so it breaks the code.
Here's a test for the current rewrite-static-analysis:
rewrite-static-analysis
--- a/src/test/java/org/openrewrite/staticanalysis/MissingOverrideAnnotationTest.java +++ b/src/test/java/org/openrewrite/staticanalysis/MissingOverrideAnnotationTest.java @@ -18,6 +18,8 @@ package org.openrewrite.staticanalysis; import org.intellij.lang.annotations.Language; import org.junit.jupiter.api.Test; import org.openrewrite.DocumentExample; +import org.openrewrite.java.RemoveObjectsIsNull; +import org.openrewrite.test.AdHocRecipe; import org.openrewrite.test.RecipeSpec; import org.openrewrite.test.RewriteTest; @@ -61,10 +63,18 @@ class MissingOverrideAnnotationTest implements RewriteTest { @Language("java") String testParentParent = """ package com.example; - + import java.lang.annotation.*; + + @Target({ElementType.TYPE_USE}) + @interface Nullable { + } + class TestParentParent { public void testParentParent() { } + + public byte @Nullable [][] get2dArray() { + } } """; @@ -125,6 +135,40 @@ class MissingOverrideAnnotationTest implements RewriteTest { ); } + @Test + void whenAMethodOverridesFromAParentArray() { + rewriteRun( + //language=java + java(testParentParent), + //language=java + java( + """ + package com.example; + + class Test extends TestParentParent { + public byte @Nullable [][] get2dArray() { + } + + public void localMethod() { + } + } + """, + """ + package com.example; + + class Test extends TestParentParent { + @Override + public byte @Nullable [][] get2dArray() { + } + + public void localMethod() { + } + } + """ + ) + ); + } +
Here's the output:
Unexpected result in "com/example/Test.java": diff --git a/com/example/Test.java b/com/example/Test.java index e977a3c..59fa0ca 100644 --- a/com/example/Test.java +++ b/com/example/Test.java @@ -2,7 +2,7 @@ class Test extends TestParentParent { @Override - public byte @Nullable [][] get2dArray() { + public byte @Nullable [] get2dArray() { } public void localMethod() { ] expected: "package com.example; class Test extends TestParentParent { @Override public byte @Nullable [][] get2dArray() { } public void localMethod() { } }"
The text was updated successfully, but these errors were encountered:
We have a PR in progress that might affect this too:
JavaType$Array
Sorry, something went wrong.
We have a PR in progress that might affect this too: Add annotations to JavaType$Array #3860
Confirmed: this issue will be fixed by #3860
traceyyoshima
Successfully merging a pull request may close this issue.
What version of OpenRewrite are you using?
The issue reproduces with the current snapshot.
MissingOverrideAnnotation converts 2d array to 1d one, so it breaks the code.
Here's a test for the current
rewrite-static-analysis
:Here's the output:
The text was updated successfully, but these errors were encountered: