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
Generics checks for parameter passing #746
Generics checks for parameter passing #746
Conversation
@@ -44,10 +44,6 @@ public void constructorTypeParamInstantiation() { | |||
" NonNullTypeParam<String> t2 = new NonNullTypeParam<@Nullable String>();", | |||
" // BUG: Diagnostic contains: Generic type parameter", | |||
" testBadNonNull(new NonNullTypeParam<@Nullable String>());", | |||
" testBadNonNull(", |
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.
Why is this deleted?
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.
Same question from me
@lazaroclapp I think this is ready for you to take a look |
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.
Some minor questions:
@@ -44,10 +44,6 @@ public void constructorTypeParamInstantiation() { | |||
" NonNullTypeParam<String> t2 = new NonNullTypeParam<@Nullable String>();", | |||
" // BUG: Diagnostic contains: Generic type parameter", | |||
" testBadNonNull(new NonNullTypeParam<@Nullable String>());", | |||
" testBadNonNull(", |
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.
Same question from me
" }", | ||
" static void testPositive(A<A<@Nullable String>> a1, A<String> a2) {", | ||
" // BUG: Diagnostic contains: Cannot pass parameter of type", | ||
" A<String> a = sampleMethod(a1, a2);", |
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.
How about the other way around? This is invariant, right? So we should also test that we can't pass A<String>
to something expecting A<@Nullable String>
, correct?
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.
Very minor comment nit, otherwise looks good to go!
for (int i = 0; i < formalParams.size(); i++) { | ||
int n = formalParams.size(); | ||
if (isVarArgs) { | ||
n = n - 1; // don't check for the last argument if |
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.
If what? I mean, it's fairly clear, but lets complete the comment. Maybe it should be a comment above like:
// If the last argument is var args, don't check it now, it will be checked against
// all remaining actual arguments in the next loop.
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.
LGTM! (@msridhar?)
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.
LGTM too! Landing
This reverts commit a1d1eed.
This reverts commit a1d1eed.
This reverts commit a1d1eed.
This reverts commit a1d1eed.
This reverts commit a1d1eed.
For method calls, the nullability annotations of the type parameters for formal parameter types and actual parameter types should be exactly the same.
This pull request adds code to compare nullability annotations of actual and formal parameters of
generic type
and reports an error if the annotations don't match. example: