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

Update handling of annotations on varargs argument #1025

Merged
merged 29 commits into from
Sep 1, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
another test
  • Loading branch information
msridhar committed Sep 1, 2024
commit bc46f2e448887afa05f03cb879a403faf2013325
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ public void testNullableVarargs() {
"public class Utilities {",
" public static String takesNullableVarargs(Object o, @Nullable Object... others) {",
" String s = o.toString() + \" \" + others.toString();",
" for (Object other : others) {",
" // no error here; requires a type-use annotation on the elements",
" s += other.toString();",
" }",
" return s;",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we be checking in here that the elements are @Nullable? By adding the for loop and trying to deref `other? Or is the table saying that in JSpecify mode (and every mode other than legacy) we don't check declaration annotations (but acknowledge them for call sites)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did add the test in bc46f2e. And I have now changed the logic so that we get an error, in 6b622c7. Great catch! My table didn't have this case as an error before, due to an attempt to make treatment of array types identical for regular arrays and varargs arrays. But there are already other cases where we don't have identical treatment. And the previous table made a @Nullable declaration annotation a no-op within the method body, which could be confusing. So this is now fixed, and I will update the table accordingly.

" }",
"}")
Expand Down