in static-analysis/autodispose-error-prone/src/main/java/autodispose2/errorprone/AbstractReturnValueIgnored.java [109:135]
public Description matchMemberReference(MemberReferenceTree tree, VisitorState state) {
boolean matches = specializedMatcher().matches(tree, state);
if (!matches) {
return Description.NO_MATCH;
}
if (lenient()) {
boolean isUnusedReturnValue =
allOf(
AbstractReturnValueIgnored::isNotConstructorReference,
AbstractReturnValueIgnored::isVoidReturningMethodReferenceExpression,
// Skip cases where the method we're referencing really does return void. We're
// only
// looking for cases where the referenced method does not return void, but it's
// being
// used on a void-returning functional interface.
not((t, s) -> isVoidType(getSymbol(tree).getReturnType(), s)),
not((t, s) -> isThrowingFunctionalInterface(s, ((JCMemberReference) t).type)))
.matches(tree, state);
if (!isUnusedReturnValue) {
if (isValidReturnValueType(tree, state)) {
return Description.NO_MATCH;
}
}
}
return describeMatch(tree);
}