Skip to content

Commit

Permalink
Fix an ArrayToString false positive for the varargs overload of `Join…
Browse files Browse the repository at this point in the history
…er.join(Object, Object, Object...)`

google#4233 (review)

PiperOrigin-RevId: 619537499
  • Loading branch information
cushon authored and Error Prone Team committed Mar 27, 2024
1 parent 9b2c2a9 commit ed4b61d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,9 @@ public Description matchMethodInvocation(MethodInvocationTree tree, VisitorState
argTree,
ToStringKind.IMPLICIT,
state);
} else {
handleStringifiedTree(argTree, ToStringKind.IMPLICIT, state);
}
handleStringifiedTree(argTree, ToStringKind.IMPLICIT, state);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,4 +199,33 @@ public void arrayPassedToJoiner() {
"}")
.doTest();
}

@Test
public void arrayPassedToJoiner_firstSecondRest_negative() {
compilationHelper
.addSourceLines(
"Test.java",
"import com.google.common.base.Joiner;",
"class Test {",
" String test(Joiner j, Object first, Object second, Object[] rest) {",
" return j.join(first, second, rest);",
" }",
"}")
.doTest();
}

@Test
public void arrayPassedToJoiner_firstSecondRest_positive() {
compilationHelper
.addSourceLines(
"Test.java",
"import com.google.common.base.Joiner;",
"class Test {",
" String test(Joiner j, Object first, Object second, Object third, Object[] rest) {",
" // BUG: Diagnostic contains:",
" return j.join(first, second, third, rest);",
" }",
"}")
.doTest();
}
}

0 comments on commit ed4b61d

Please sign in to comment.