Skip to content

Commit

Permalink
Do the expensive bit last in UnusedMethod.
Browse files Browse the repository at this point in the history
Healthier: []
PiperOrigin-RevId: 498170447
  • Loading branch information
graememorgan authored and Error Prone Team committed Dec 28, 2022
1 parent e360257 commit 1d23141
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,7 @@ private boolean isMethodSymbolEligibleForChecking(
return false;
}
MethodSymbol methodSymbol = getSymbol(tree);
if (!methodSymbol.isPrivate()
&& classesMadeVisible.stream()
.anyMatch(t -> isSubtype(t.type, methodSymbol.owner.type, state))) {
if (!canBeRemoved(methodSymbol, state)) {
return false;
}
if (isExemptedConstructor(methodSymbol, state)
Expand All @@ -271,8 +269,13 @@ private boolean isMethodSymbolEligibleForChecking(
return false;
}
}
if (!methodSymbol.isPrivate()
&& classesMadeVisible.stream()
.anyMatch(t -> isSubtype(t.type, methodSymbol.owner.type, state))) {
return false;
}

return canBeRemoved(methodSymbol, state);
return true;
}

private boolean isExemptedConstructor(MethodSymbol methodSymbol, VisitorState state) {
Expand Down

0 comments on commit 1d23141

Please sign in to comment.