-
Notifications
You must be signed in to change notification settings - Fork 299
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
Ignore incompatibly annotated var args from Kotlin code. #721
Ignore incompatibly annotated var args from Kotlin code. #721
Conversation
Pull Request Test Coverage Report for Build #1041
💛 - Coveralls |
" Utilities.takesNullableVarargs(o1, o4);", | ||
" Utilities.takesNullableVarargs(o1, (java.lang.Object) null);", | ||
// SHOULD be an error! | ||
" Utilities.takesNullableVarargs(o1, (java.lang.Object[]) null);", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turns out there is a way to pass null varargs array from Java 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, interesting. Didn't think of this one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change LGTM and I agree it's the best we can do for the moment to address this issue
" Utilities.takesNullableVarargs(o1, o4);", | ||
" Utilities.takesNullableVarargs(o1, (java.lang.Object) null);", | ||
// SHOULD be an error! | ||
" Utilities.takesNullableVarargs(o1, (java.lang.Object[]) null);", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, interesting. Didn't think of this one
See #720 for a detailed explanation.
Long story short:
kotlinc
will add@org.jetbrains.annotations.NotNull
as a declaration annotation for any argument that is non-null, which we pick up from jars when running withAcknowledgeRestrictiveAnnotations=true
.open fun w(vararg args: Any?)
as having@NotNull args
(meaning the array itself).w(@NotNull Object... args)
, which we believe should be interpreted as marking the elements ofargs
as being@NotNull
.RestrictiveAnnotationHandler
to skip@org.jetbrains.annotations.NotNull
on var args only.Additionally, our basic handling of var args is pretty broken. I went over our test cases and commented where I think our current behavior is different from the desired behavior as documented in #720 and #674. Foregoing fixing it for now, as I am worried about the breaking change and I think we want to avoid changing that before 0.10.9.