Skip to content

Commit

Permalink
[javac] Check in OptimizeAutoValue that the implicit supercall remove…
Browse files Browse the repository at this point in the history
…d is the first statement.

PiperOrigin-RevId: 702791620
  • Loading branch information
Googler authored and copybara-github committed Dec 4, 2024
1 parent 75f5e8d commit 797a460
Showing 1 changed file with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,10 @@ private static void removeImplicitSuperConstructorCalls(Library library) {

ExpressionStatement constructorInvocationStatement =
AstUtils.getConstructorInvocationStatement(ctor);
if (ctor.getBody().getStatements().indexOf(constructorInvocationStatement) != 0) {
// Exclude super calls that are not the first statement. This is to avoid
// incorrectly reordering when there are statements before the super call (for
// example, captures), because this would remove the super call in the middle and
// then we later currently only add the calls back at the beginning.
// TODO(b/382109887): Make sure this behaves consistently with jdt.
continue;
}
// The super call for AutoValue should always be the first statement. Captures, for
// example, are not possible. AutoValue does not support inner nor local classes.
checkState(
ctor.getBody().getStatements().indexOf(constructorInvocationStatement) == 0);

MethodCall superConstructorCall =
(MethodCall) constructorInvocationStatement.getExpression();
Expand Down

0 comments on commit 797a460

Please sign in to comment.