Skip to content

Commit fba919b

Browse files
nick-someoneError Prone Team
authored and
Error Prone Team
committed
Fix consistency of isCovered() in CheckReturnValue
PiperOrigin-RevId: 439392998
1 parent 2ea4d44 commit fba919b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

core/src/main/java/com/google/errorprone/bugpatterns/CheckReturnValue.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,9 @@ private static Optional<MethodSymbol> methodSymbol(ExpressionTree tree) {
110110

111111
@Override
112112
public boolean isCovered(ExpressionTree tree, VisitorState state) {
113-
return methodSymbol(tree).flatMap(CheckReturnValue::firstAnnotation).isPresent();
113+
return methodSymbol(tree)
114+
.map(m -> (checkAllConstructors && m.isConstructor()) || firstAnnotation(m).isPresent())
115+
.orElse(false);
114116
}
115117

116118
@Override

0 commit comments

Comments
 (0)