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

Parser does not handle annotated varargs correctly #4628

Draft
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

Laurens-W
Copy link
Contributor

@Laurens-W Laurens-W commented Oct 30, 2024

What's changed?

Added reproducer testcase

What's your motivation?

Checklist

  • I've added unit tests to cover both positive and negative cases
  • I've read and applied the recipe conventions and best practices
  • I've used the IntelliJ IDEA auto-formatter on affected files

@Laurens-W Laurens-W self-assigned this Oct 31, 2024
@Laurens-W Laurens-W marked this pull request as ready for review October 31, 2024 18:45
@traceyyoshima
Copy link
Contributor

As a sanity check, I suggest looking at a few things:

  1. The Java type of typeExpression on J.AnnotatedType.
  2. If the solution will apply to code like void m ( String @NonNull [ ] @NonNull ... s ) { }

@timtebeek
Copy link
Contributor

Thanks for the helpful counter example @traceyyoshima ! That indeed still fails; when I revert the printer changes I see:

diff --git a/C2.java b/C2.java
index 2b026e1..326aa32 100644
--- a/C2.java
+++ b/C2.java
@@ -1,6 +1,6 @@ 
 import org.jspecify.annotations.NonNull;
 
 class C2 {
-    void m(@NonNull String @NonNull ... varArgs) {
+    void m(@NonNull String @NonNull[] ... varArgs) {
     }
 }
diff --git a/C3.java b/C3.java
index 108e4b9..389aba9 100644
--- a/C3.java
+++ b/C3.java
@@ -1,6 +1,6 @@ 
 import org.jspecify.annotations.NonNull;
 
 class C3 {
-    void m(String @NonNull [ ] @NonNull ... s) {
+    void m(String @NonNull [ ] ... s) {
     }
 }

@timtebeek timtebeek marked this pull request as draft November 1, 2024 23:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working parser-java
Projects
Status: Ready to Review
Development

Successfully merging this pull request may close these issues.

3 participants