Skip to content

Commit

Permalink
Fix off-by-one error in JSpecify checking of parameter passing (#793)
Browse files Browse the repository at this point in the history
Not sure how we missed this before...
  • Loading branch information
msridhar committed Jul 31, 2023
1 parent 8e4a36a commit e711887
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ public void compareGenericTypeParameterNullabilityForCall(
// all remaining actual arguments in the next loop.
n = n - 1;
}
for (int i = 0; i < n - 1; i++) {
for (int i = 0; i < n; i++) {
Type formalParameter = formalParams.get(i).type;
if (!formalParameter.getTypeArguments().isEmpty()) {
Type actualParameter = getTreeType(actualParams.get(i));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public void constructorTypeParamInstantiation() {
" // BUG: Diagnostic contains: Generic type parameter",
" testBadNonNull(new NonNullTypeParam<@Nullable String>());",
" testBadNonNull(",
" // BUG: Diagnostic contains: Cannot pass parameter of type NonNullTypeParam<@Nullable String>",
" new NonNullTypeParam<",
" // BUG: Diagnostic contains: Generic type parameter",
" @Nullable String>());",
Expand Down Expand Up @@ -677,6 +678,8 @@ public void parameterPassing() {
" static A<String> sampleMethod2(A<A<@Nullable String>> a1, A<String> a2) {",
" return a2;",
" }",
" static void sampleMethod3(A<@Nullable String> a1) {",
" }",
" static void testPositive1(A<A<@Nullable String>> a1, A<String> a2) {",
" // BUG: Diagnostic contains: Cannot pass parameter of type A<A<@Nullable String>>",
" A<String> a = sampleMethod1(a1, a2);",
Expand All @@ -685,6 +688,10 @@ public void parameterPassing() {
" // BUG: Diagnostic contains: Cannot pass parameter of type",
" A<String> a = sampleMethod2(a1, a2);",
" }",
" static void testPositive3(A<String> a1) {",
" // BUG: Diagnostic contains: Cannot pass parameter of type",
" sampleMethod3(a1);",
" }",
" static void testNegative(A<A<String>> a1, A<String> a2) {",
" A<String> a = sampleMethod1(a1, a2);",
" }",
Expand Down

0 comments on commit e711887

Please sign in to comment.