Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import static com.google.errorprone.fixes.SuggestedFixes.qualifyType;
import static com.google.errorprone.matchers.Description.NO_MATCH;
import static com.google.errorprone.util.ASTHelpers.getSymbol;
import static com.google.errorprone.util.ASTHelpers.hasAnnotation;
import static com.google.errorprone.util.ASTHelpers.isSameType;
import static com.google.errorprone.util.ASTHelpers.isSubtype;
import static java.lang.Boolean.TRUE;
Expand Down Expand Up @@ -57,6 +58,9 @@ public Description matchMethod(MethodTree tree, VisitorState state) {
if (tree.getBody() == null) {
return NO_MATCH;
}
if (hasAnnotation(tree, CRV, state)) {
return Description.NO_MATCH;
}
if (!instanceReturnsBuilder(sym, state)) {
return NO_MATCH;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public void negative() {
testHelper
.addInputLines(
"Test.java",
"import com.google.errorprone.annotations.CheckReturnValue;",
"",
"class Test {",
" static class TestBuilder {",
" static TestBuilder builder() {",
Expand All @@ -58,6 +60,10 @@ public void negative() {
" TestBuilder setParens(String bar) {",
" return (this);",
" }",
" @CheckReturnValue",
" TestBuilder dontFlag(String flag) {",
" return new TestBuilder();",
" }",
" }",
"}")
.expectUnchanged()
Expand Down