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

Generics checks for parameter passing #746

Merged
merged 261 commits into from
Mar 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
261 commits
Select commit Hold shift + click to select a range
90d471d
tweak error message
msridhar Oct 3, 2022
98f7fa6
more tests
msridhar Oct 3, 2022
53ddad7
code cleanup.remove print statements
NikitaAware Oct 3, 2022
7daa52b
Add temporary check to consider unannoted base type
NikitaAware Oct 3, 2022
cd01ff9
minor code changes
NikitaAware Oct 4, 2022
202d5db
add generics check for new class - check if the class is generic
NikitaAware Oct 6, 2022
3998949
add generics check for new class - check for the type arguments
NikitaAware Oct 7, 2022
fc8b99f
generics check for new class
NikitaAware Oct 10, 2022
6425909
generics check for extended class
NikitaAware Oct 10, 2022
bae84dc
generics check for new class
NikitaAware Oct 10, 2022
4aba42c
generics check for new class - minor changes for error message
NikitaAware Oct 10, 2022
bca4f24
generics check for interface implementation
NikitaAware Oct 10, 2022
99e8bf9
minor identation changes
NikitaAware Oct 10, 2022
a0caac8
nullability checks for build failures
NikitaAware Oct 11, 2022
5b9d918
Add Test: generics check for subclasses
NikitaAware Oct 11, 2022
4cb51d9
restructure generics tests
NikitaAware Oct 11, 2022
2e4a2ef
restructure generics tests
NikitaAware Oct 11, 2022
b1668e9
Add tests
NikitaAware Oct 11, 2022
9c8b3ae
restructure code
NikitaAware Oct 11, 2022
97e088b
restructure code
NikitaAware Oct 11, 2022
036febf
restructure code
NikitaAware Oct 11, 2022
f065bd9
Merge branch 'master' into add-generics-checks
msridhar Oct 11, 2022
00ad702
add jspecify mode flag
msridhar Oct 11, 2022
31a0e4d
check jspecify flag
msridhar Oct 11, 2022
fe66b4a
add test case for nested type parameter instantiation
msridhar Oct 11, 2022
89ca225
nested type
NikitaAware Oct 13, 2022
8ba736b
nested generics type check for new class
NikitaAware Oct 13, 2022
fa627be
Add test - generics check for function return type
NikitaAware Oct 14, 2022
5745cf7
Add - generics check for function return type
NikitaAware Oct 14, 2022
1518629
code cleaning - generics check
NikitaAware Oct 18, 2022
b25ba39
code cleaning - generics check
NikitaAware Oct 18, 2022
bd96079
Merge branch 'master' into add-generics-checks
msridhar Oct 19, 2022
975dccd
Suggested changes
NikitaAware Oct 23, 2022
6d22b00
Suggested changes
NikitaAware Oct 23, 2022
2ddbea9
Suggested changes
NikitaAware Oct 25, 2022
b9cbbff
working changes
NikitaAware Oct 25, 2022
2002aec
working changes
NikitaAware Oct 25, 2022
5c11fbe
suggested changes
NikitaAware Oct 25, 2022
736a613
suggested changes
NikitaAware Oct 27, 2022
80ba7a5
suggested changes
NikitaAware Oct 27, 2022
e1864ee
suggested changes
NikitaAware Oct 27, 2022
8d5e193
extend test
msridhar Oct 27, 2022
91aab18
@Nullable annotation check for Paramterized typed tree
NikitaAware Oct 27, 2022
799f5dc
@Nullable annotation check for Paramterized typed tree
NikitaAware Oct 27, 2022
f042e60
added updates
NikitaAware Nov 1, 2022
852e4b1
added updates
NikitaAware Nov 1, 2022
8b484c2
extra test cases for other annotations
NikitaAware Nov 1, 2022
1727458
extra test cases for other annotations
NikitaAware Nov 1, 2022
7ecc2c4
Merge branch 'master' into add-generics-checks
NikitaAware Nov 1, 2022
f0a0b62
some comments and a todo
msridhar Nov 3, 2022
bc3c0be
reuse code
msridhar Nov 6, 2022
832f733
minor cleanup
msridhar Nov 6, 2022
0b5268c
fix
msridhar Nov 6, 2022
66a1068
Suggested changes
NikitaAware Nov 6, 2022
1bc1ea6
Suggested changes
NikitaAware Nov 6, 2022
cb1690a
Suggested changes
NikitaAware Nov 6, 2022
c523f2d
Javadoc tweaks
msridhar Nov 7, 2022
8cf3819
add private constructor
msridhar Nov 7, 2022
27d5488
suggested changes
NikitaAware Nov 10, 2022
263edac
suggested changes
NikitaAware Nov 10, 2022
2fa8569
suggested changes
NikitaAware Nov 10, 2022
f40a0da
suggested changes
NikitaAware Nov 10, 2022
8308cf6
code cleanup
msridhar Nov 10, 2022
af6404a
tests for error positions
msridhar Nov 10, 2022
ad67e01
Clean up by implementing ParameterizedTypeTreeMatcher
msridhar Nov 11, 2022
67994da
remove extra blank line
msridhar Nov 11, 2022
2631d63
add test
msridhar Nov 11, 2022
36a5c60
suggested changes
NikitaAware Nov 16, 2022
c8ebfe6
suggested changes
NikitaAware Nov 16, 2022
938c595
Merge branch 'master' into add-generics-checks
msridhar Nov 16, 2022
3fb6856
tweak error message
msridhar Nov 16, 2022
ee57c56
clarify test name and purpose
msridhar Nov 16, 2022
7349744
Assignment interface added
NikitaAware Nov 16, 2022
b5eb8a0
structure for assignments checks
NikitaAware Nov 16, 2022
eecc4c3
Assignment changes
NikitaAware Nov 18, 2022
063c580
supertype changes
NikitaAware Dec 7, 2022
696aa90
Merge branch 'master' into assigments1
NikitaAware Dec 9, 2022
823da48
multiple interface implementation
NikitaAware Dec 9, 2022
e26e088
multilevel inheritance
NikitaAware Dec 9, 2022
f7009ae
changes
NikitaAware Dec 9, 2022
3b2cdf1
changes
NikitaAware Dec 9, 2022
d957f56
nested checks
NikitaAware Dec 9, 2022
2d061fc
working changes
NikitaAware Dec 9, 2022
80f296e
working changes
NikitaAware Dec 9, 2022
c33fe3f
Working changes
NikitaAware Dec 9, 2022
31a3dca
updates
NikitaAware Dec 10, 2022
3eca5a3
failing 3 tests
NikitaAware Dec 15, 2022
3435f89
working tests
NikitaAware Dec 16, 2022
7972c05
npe for variable initialization changes
NikitaAware Dec 20, 2022
4924722
npe for variable initialization changes
NikitaAware Dec 20, 2022
35e2bc7
All tests pass including the existing tests
NikitaAware Dec 20, 2022
a59d223
Merge branch 'master' into assigments1
msridhar Dec 21, 2022
25b840b
Merge branch 'master' into assigments1
msridhar Dec 21, 2022
c8456f3
some cleanup
msridhar Dec 21, 2022
945df87
enable check for multiple top-level classes
msridhar Dec 21, 2022
a3fa869
suggested changes - enclosing class member fields
NikitaAware Jan 3, 2023
601f2b5
code cleanup
NikitaAware Jan 3, 2023
a0aacdb
suggested changes
NikitaAware Jan 3, 2023
7b39522
Merge branch 'master' into assigments1
msridhar Jan 4, 2023
84140d0
some suggested changes
NikitaAware Jan 4, 2023
20fae01
suggested changes with working normal typed tree
NikitaAware Jan 4, 2023
c517b4b
Changes with parameterized typed tree without the error generation
NikitaAware Jan 4, 2023
def7ce2
suggested changes with two test cases failing
NikitaAware Jan 4, 2023
75f36df
suggested changes with all passing tests
NikitaAware Jan 4, 2023
0125647
All working changes
NikitaAware Jan 4, 2023
8fc5d18
Continuous integration working
NikitaAware Jan 4, 2023
090ac0c
Continuous integration working
NikitaAware Jan 4, 2023
ba6b229
changes
NikitaAware Jan 4, 2023
bd6700f
minor changes
NikitaAware Jan 4, 2023
fd0b096
fix naming case
msridhar Jan 4, 2023
d5f34f2
failing test
msridhar Jan 4, 2023
01c5503
refactoring and comments
msridhar Jan 4, 2023
25599dd
add a case
msridhar Jan 4, 2023
bf80848
working code with class type
NikitaAware Jan 6, 2023
8ca41d0
minor refactoring
NikitaAware Jan 6, 2023
4a87b6c
minor changes
NikitaAware Jan 6, 2023
44bea9b
code cleaning
NikitaAware Jan 6, 2023
b9a2ed4
code cleaning
NikitaAware Jan 6, 2023
ac7f33a
fancy test works!
msridhar Jan 7, 2023
851fbfa
Merge branch 'master' into assigments1
msridhar Jan 7, 2023
b1119ab
only run check in JSpecify mode
msridhar Jan 7, 2023
92989ec
Fix NullAway errors
msridhar Jan 7, 2023
334d1e8
modified assignment message
NikitaAware Jan 7, 2023
79b474b
remove unneeded suppression
msridhar Jan 7, 2023
05292c0
remove change to build.gradle
msridhar Jan 7, 2023
d9e2689
remove local used only once
msridhar Jan 7, 2023
1cc72f2
cleanup supertypeMatchingLHS
msridhar Jan 7, 2023
85741be
restore private
msridhar Jan 7, 2023
c58d819
add private
msridhar Jan 7, 2023
8829bcd
changed the error message
NikitaAware Jan 8, 2023
fd16446
updated the error message text
NikitaAware Jan 8, 2023
c0fd28e
Type.ClassType suggestion changes
NikitaAware Jan 8, 2023
abe3ed9
changes
NikitaAware Jan 8, 2023
7a18462
changes
NikitaAware Jan 8, 2023
23c8fbb
changes
NikitaAware Jan 8, 2023
88accab
extra test case
NikitaAware Jan 8, 2023
124e7c8
add failing test
msridhar Jan 8, 2023
00802a1
updated logic
NikitaAware Jan 8, 2023
021435a
minor updates
NikitaAware Jan 8, 2023
a12d549
minor code cleaning
NikitaAware Jan 8, 2023
82d9e8d
minor code cleaning
NikitaAware Jan 8, 2023
f381d83
suggested changes
NikitaAware Jan 9, 2023
75234b8
suggested changes
NikitaAware Jan 9, 2023
1be7c40
replaced super type matching lhs with asSuper method
NikitaAware Jan 9, 2023
676e07d
updated assignment checks
NikitaAware Jan 10, 2023
a085443
changes
NikitaAware Jan 10, 2023
c8303d7
changes
NikitaAware Jan 10, 2023
4238a9a
suggested changes
NikitaAware Jan 10, 2023
f5ec4cd
suggested changes
NikitaAware Jan 10, 2023
257c42c
suggested changes
NikitaAware Jan 10, 2023
a9e4890
suggested changes
NikitaAware Jan 10, 2023
f3fd30d
suggested changes
NikitaAware Jan 10, 2023
c2f66e2
Merge branch 'master' into assigments1
msridhar Jan 11, 2023
aeddd14
fix nullaway error
msridhar Jan 11, 2023
c67db12
Merge branch 'master' into assigments1
msridhar Jan 11, 2023
e244e55
fixes
msridhar Jan 11, 2023
53f8546
more cleanup and javadoc
msridhar Jan 11, 2023
0fe788d
Merge branch 'master' into assigments1
msridhar Jan 14, 2023
3fb81c9
Merge branch 'master' into assigments1
msridhar Jan 20, 2023
0bfe208
Merge branch 'master' into assigments1
msridhar Jan 22, 2023
d6bc810
suggested changes in test nestedChecksForAssignmentsMultipleArguments
NikitaAware Jan 23, 2023
3127339
suggested changes in test - superTypeAssignmentChecksSingleInterface
NikitaAware Jan 23, 2023
4aacb5a
suggested indentation changes in test - superTypeAssignmentChecksMult…
NikitaAware Jan 23, 2023
f3e6b45
suggested changes
NikitaAware Jan 23, 2023
38f2ef6
suggested changes
NikitaAware Jan 23, 2023
5245c4d
suggested test for the lambda expressions
NikitaAware Jan 23, 2023
0344360
Java doc for type with preserved annotations
NikitaAware Jan 23, 2023
00cad6f
comments
NikitaAware Jan 23, 2023
d09c190
code cleaning for the tests
NikitaAware Jan 23, 2023
8bb552c
code cleaning for the tests
NikitaAware Jan 23, 2023
0cff82f
changes
NikitaAware Jan 23, 2023
9906f25
suggested changes
NikitaAware Jan 23, 2023
f6dcc69
negative tests
NikitaAware Jan 23, 2023
4323d48
fix formatting in tests
msridhar Jan 23, 2023
5ec8fa1
test cases for diamond operator and the lambdas
NikitaAware Jan 24, 2023
7c07d98
test cases for diamond operator and the lambdas
NikitaAware Jan 24, 2023
6755d66
private fields
NikitaAware Jan 25, 2023
41f45b1
check only for jspecify nullable annotation
NikitaAware Jan 25, 2023
322c3c2
move test method to more appropriate place
msridhar Jan 25, 2023
4a46a46
tweak method reference test
msridhar Jan 25, 2023
4a1ce05
re-add blank line
msridhar Jan 25, 2023
fce345b
clarify method ref test
msridhar Jan 25, 2023
02bbd9f
tweak lambda and diamond operator tests
msridhar Jan 25, 2023
514829d
make test Java 8 compatible
msridhar Jan 26, 2023
2270d8d
Merge branch 'master' into assigments1
msridhar Jan 31, 2023
924883b
Merge branch 'master' into assigments1
msridhar Feb 1, 2023
c070c22
Merge branch 'master' into assigments1
msridhar Feb 6, 2023
e37aa61
Merge branch 'master' into assigments1
msridhar Feb 6, 2023
7412439
suggested changes
NikitaAware Feb 7, 2023
228cf0f
suggested changes
NikitaAware Feb 7, 2023
b7bbf7c
suggested changes
NikitaAware Feb 7, 2023
edb4f86
suggested changes
NikitaAware Feb 7, 2023
18f3134
Merge branch 'master' into assigments1
lazaroclapp Feb 7, 2023
49a113f
function call
NikitaAware Feb 10, 2023
bb9212e
function changes
NikitaAware Feb 10, 2023
bb246e2
tests
NikitaAware Feb 10, 2023
410c130
tests
NikitaAware Feb 10, 2023
de0ca7f
funtions
NikitaAware Feb 10, 2023
105f557
changes
NikitaAware Feb 10, 2023
1490648
fix bad diff with master
msridhar Feb 12, 2023
38429d4
Merge branch 'master' into generics-return-type-changes
msridhar Feb 12, 2023
40ffe4e
Merge branch 'generics-return-type-changes' into generics-ternary-ope…
msridhar Feb 12, 2023
f03bb05
fix nullaway warning
msridhar Feb 12, 2023
51b351f
fix tests
msridhar Feb 12, 2023
309db13
Merge branch 'generics-return-type-changes' into generics-ternary-ope…
msridhar Feb 12, 2023
52825a2
fix
msridhar Feb 12, 2023
b4982ea
change approach
msridhar Feb 12, 2023
6493985
add another test case
msridhar Feb 13, 2023
76093ab
suggested changes
NikitaAware Feb 13, 2023
ea40f7d
suggested changes
NikitaAware Feb 13, 2023
824ed42
error message return changes
NikitaAware Feb 13, 2023
4651fe9
suggested changes
NikitaAware Feb 13, 2023
1921bd1
suggested changes
NikitaAware Feb 14, 2023
090fd56
suggested changes
NikitaAware Feb 14, 2023
6dde586
Merge branch 'generics-return-type-changes' into generics-ternary-ope…
msridhar Feb 14, 2023
e8ff4b3
Update nullaway/src/main/java/com/uber/nullaway/GenericsChecks.java
NikitaAware Feb 15, 2023
142a820
updated error message
NikitaAware Feb 15, 2023
5344b5b
updated error message
NikitaAware Feb 15, 2023
b37c0ab
updated error message
NikitaAware Feb 15, 2023
afcf86e
Merge branch 'generics-return-type-changes' into generics-ternary-ope…
msridhar Feb 15, 2023
4fe9435
updated error message
NikitaAware Feb 15, 2023
933d77e
test
NikitaAware Feb 15, 2023
c393149
test
NikitaAware Feb 15, 2023
04b215c
method
NikitaAware Feb 15, 2023
d8fae04
update method name
NikitaAware Feb 17, 2023
cbda35b
javadoc
NikitaAware Feb 17, 2023
cd8c8e2
updated error message
NikitaAware Feb 17, 2023
fbc7ed7
updated error message
NikitaAware Feb 17, 2023
f73b54c
suggested changes
NikitaAware Feb 17, 2023
44c7d28
updated test
NikitaAware Feb 17, 2023
175bf72
updated test
NikitaAware Feb 17, 2023
ce566ad
new error message type
NikitaAware Feb 19, 2023
448c298
vararg support
NikitaAware Feb 19, 2023
64b9be0
Update nullaway/src/main/java/com/uber/nullaway/GenericsChecks.java
NikitaAware Feb 19, 2023
07dca0a
formatting
msridhar Feb 20, 2023
6287e96
clarify docs and add test
msridhar Feb 20, 2023
615abdc
tweak error message
msridhar Feb 22, 2023
64d3233
separate out varargs test
msridhar Feb 22, 2023
2b3caac
improve test
msridhar Feb 22, 2023
99737e5
correct varargs check
msridhar Feb 22, 2023
4820854
Merge branch 'master' into generics-ternary-operator-assignment-changes
msridhar Feb 22, 2023
7697c13
Merge branch 'generics-ternary-operator-assignment-changes' into gene…
msridhar Feb 22, 2023
f96631b
minor changes in a test case
NikitaAware Feb 22, 2023
6c82338
Merge branch 'generics-ternary-operator-assignment-changes' into gene…
msridhar Mar 1, 2023
3fb9c6f
Merge branch 'master' into generics-checks-for-parameter-passing
msridhar Mar 10, 2023
ecc5d51
cleanup and docs
msridhar Mar 10, 2023
5ab576e
suggested changes
NikitaAware Mar 17, 2023
6222585
test case
NikitaAware Mar 17, 2023
e6442a2
suggested changes
NikitaAware Mar 17, 2023
fed2004
suggested change
NikitaAware Mar 18, 2023
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
1 change: 1 addition & 0 deletions nullaway/src/main/java/com/uber/nullaway/ErrorMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public enum MessageTypes {
TYPE_PARAMETER_CANNOT_BE_NULLABLE,
ASSIGN_GENERIC_NULLABLE,
RETURN_NULLABLE_GENERIC,
PASS_NULLABLE_GENERIC,
}

public String getMessage() {
Expand Down
75 changes: 75 additions & 0 deletions nullaway/src/main/java/com/uber/nullaway/GenericsChecks.java
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,26 @@ private static void reportMismatchedTypeForTernaryOperator(
errorMessage, analysis.buildDescription(tree), state, null));
}

private void reportInvalidParametersNullabilityError(
Type formalParameterType,
Type actualParameterType,
ExpressionTree paramExpression,
VisitorState state,
NullAway analysis) {
ErrorBuilder errorBuilder = analysis.getErrorBuilder();
ErrorMessage errorMessage =
new ErrorMessage(
ErrorMessage.MessageTypes.PASS_NULLABLE_GENERIC,
"Cannot pass parameter of type "
+ actualParameterType
+ ", as formal parameter has type "
+ formalParameterType
+ ", which has mismatched type parameter nullability");
state.reportMatch(
errorBuilder.createErrorDescription(
errorMessage, analysis.buildDescription(paramExpression), state, null));
}

/**
* This method returns the type of the given tree, including any type use annotations.
*
Expand Down Expand Up @@ -429,4 +449,59 @@ public void checkTypeParameterNullnessForConditionalExpression(ConditionalExpres
}
}
}

/**
* Checks that for each parameter p at a call, the type parameter nullability for p's type matches
* that of the corresponding formal parameter. If a mismatch is found, report an error.
*
* @param formalParams the formal parameters
* @param actualParams the actual parameters
* @param isVarArgs true if the call is to a varargs method
*/
public void compareGenericTypeParameterNullabilityForCall(
List<Symbol.VarSymbol> formalParams,
List<? extends ExpressionTree> actualParams,
boolean isVarArgs) {
if (!config.isJSpecifyMode()) {
return;
}
int n = formalParams.size();
if (isVarArgs) {
// 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.
n = n - 1;
}
for (int i = 0; i < n - 1; i++) {
Type formalParameter = formalParams.get(i).type;
if (!formalParameter.getTypeArguments().isEmpty()) {
Type actualParameter = getTreeType(actualParams.get(i));
if (formalParameter instanceof Type.ClassType
&& actualParameter instanceof Type.ClassType) {
if (!compareNullabilityAnnotations(
(Type.ClassType) formalParameter, (Type.ClassType) actualParameter)) {
reportInvalidParametersNullabilityError(
formalParameter, actualParameter, actualParams.get(i), state, analysis);
}
}
}
}
if (isVarArgs && !formalParams.isEmpty()) {
Type.ArrayType varargsArrayType =
(Type.ArrayType) formalParams.get(formalParams.size() - 1).type;
Type varargsElementType = varargsArrayType.elemtype;
if (varargsElementType.getTypeArguments().size() > 0) {
for (int i = formalParams.size() - 1; i < actualParams.size(); i++) {
msridhar marked this conversation as resolved.
Show resolved Hide resolved
Type actualParameter = getTreeType(actualParams.get(i));
if (varargsElementType instanceof Type.ClassType
&& actualParameter instanceof Type.ClassType) {
if (!compareNullabilityAnnotations(
(Type.ClassType) varargsElementType, (Type.ClassType) actualParameter)) {
reportInvalidParametersNullabilityError(
varargsElementType, actualParameter, actualParams.get(i), state, analysis);
}
}
}
}
}
}
}
3 changes: 3 additions & 0 deletions nullaway/src/main/java/com/uber/nullaway/NullAway.java
Original file line number Diff line number Diff line change
Expand Up @@ -1624,6 +1624,9 @@ private Description handleInvocation(
: Nullness.NONNULL;
}
}
new GenericsChecks(state, config, this)
.compareGenericTypeParameterNullabilityForCall(
formalParams, actualParams, methodSymbol.isVarArgs());
}

// Allow handlers to override the list of non-null argument positions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,62 @@ public void ternaryMismatchedAssignmentContext() {
.doTest();
}

@Test
public void parameterPassing() {
makeHelper()
.addSourceLines(
"Test.java",
"package com.uber;",
"import org.jspecify.annotations.Nullable;",
"class Test {",
"static class A<T extends @Nullable Object> { }",
" static A<String> sampleMethod1(A<A<String>> a1, A<String> a2) {",
" return a2;",
" }",
" static A<String> sampleMethod2(A<A<@Nullable String>> a1, A<String> a2) {",
" return a2;",
" }",
" static void testPositive1(A<A<@Nullable String>> a1, A<String> a2) {",
" // BUG: Diagnostic contains: Cannot pass parameter of type",
" A<String> a = sampleMethod1(a1, a2);",
" }",
" static void testPositive2(A<A<String>> a1, A<String> a2) {",
" // BUG: Diagnostic contains: Cannot pass parameter of type",
" A<String> a = sampleMethod2(a1, a2);",
" }",
" static void testNegative(A<A<String>> a1, A<String> a2) {",
" A<String> a = sampleMethod1(a1, a2);",
" }",
"}")
.doTest();
}

@Test
public void varargsParameter() {
makeHelper()
.addSourceLines(
"Test.java",
"package com.uber;",
"import org.jspecify.annotations.Nullable;",
"class Test {",
" static class A<T extends @Nullable Object> { }",
" static A<@Nullable String> sampleMethodWithVarArgs(A<String>... args) {",
" return new A<@Nullable String>();",
" }",
" static void testPositive(A<@Nullable String> a1, A<String> a2) {",
" // BUG: Diagnostic contains: Cannot pass parameter of type",
" A<@Nullable String> b = sampleMethodWithVarArgs(a1);",
" // BUG: Diagnostic contains: Cannot pass parameter of type",
" A<@Nullable String> b2 = sampleMethodWithVarArgs(a2, a1);",
" }",
" static void testNegative(A<String> a1, A<String> a2) {",
" A<@Nullable String> b = sampleMethodWithVarArgs(a1);",
" A<@Nullable String> b2 = sampleMethodWithVarArgs(a2, a1);",
" }",
"}")
.doTest();
}

private CompilationTestHelper makeHelper() {
return makeTestHelperWithArgs(
Arrays.asList(
Expand Down