-
Notifications
You must be signed in to change notification settings - Fork 746
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[StatementSwitchToExpressionSwitch] Combine immediately-preceding variable definitions with assignment switches to the same variable, where feasible #4730
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some drive-by comments.
assignmentSwitchAnalysisState.assignmentTargetOptional(), | ||
variableTreeOptional.get()); | ||
|
||
System.out.println("XXX compatibleVariableDeclaration: " + compatibleVariableDeclaration); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Likely to also be caught by Google-internal code review, but: I assume these stdout print statements are meant to be dropped before the PR is merged 👀
if (precedingStatements.get(precedingStatements.size() - 1) instanceof VariableTree | ||
&& precedingStatements.get(precedingStatements.size() - 2) instanceof VariableTree) { | ||
|
||
VariableTree variableTree1 = | ||
(VariableTree) precedingStatements.get(precedingStatements.size() - 1); | ||
VariableTree variableTree2 = | ||
(VariableTree) precedingStatements.get(precedingStatements.size() - 2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (precedingStatements.get(precedingStatements.size() - 1) instanceof VariableTree | |
&& precedingStatements.get(precedingStatements.size() - 2) instanceof VariableTree) { | |
VariableTree variableTree1 = | |
(VariableTree) precedingStatements.get(precedingStatements.size() - 1); | |
VariableTree variableTree2 = | |
(VariableTree) precedingStatements.get(precedingStatements.size() - 2); | |
if (precedingStatements.get(precedingStatements.size() - 1) instanceof VariableTree variableTree1 | |
&& precedingStatements.get(precedingStatements.size() - 2) instanceof VariableTree variableTree2) { |
(A similar simplification is possible below.)
9351dd6
to
4006d62
Compare
90071a9
to
6bb99a7
Compare
6bb99a7
to
afe0fbb
Compare
afe0fbb
to
f15b6a2
Compare
15e308b
to
5ce3954
Compare
…iable definitions with assignment switches to the same variable, where feasible PiperOrigin-RevId: 713355872
5ce3954
to
1a14c75
Compare
[StatementSwitchToExpressionSwitch] Combine immediately-preceding variable definitions with assignment switches to the same variable, where feasible