Small fix in NormalizeMultiexpressions.
Changes the order of operations in the pass to guarantee that all multiexpressions will be properly flattened after applying this pass. The change has no effect in our current codebase, since the situation that it fixes does not yet exist.
@@ -39,8 +39,13 @@ import java.util.stream.Collectors;
public class NormalizeMultiExpressions extends NormalizationPass {
@Override
public void applyTo(CompilationUnit compilationUnit) {
- compilationUnit.accept(new FlattenMultiExpressions());
+ // First remove multexpressions from lhs of assignments, compound agnments and operands of
+ // incements and decrements. Many passes and the final output pass expect those places to
+ // contain plain lvalues and not multiexpressions.
+ // This needs to be done before flattening since it introduces a multiexpression that could be
+ // flattened, e.g. ( (a, b) = rhs) => (a , (b = rhs)) => (a, b = rhs).
compilationUnit.accept(new SwitchMultiExpressionsAndSideEffectingExpressions());
+ compilationUnit.accept(new FlattenMultiExpressions());
}
private static class FlattenMultiExpressions extends AbstractRewriter {
