Skip to content

Normalize then/else to always be blocks in Java AST #10239

@niloc132

Description

@niloc132

An old TODO in Simplifier suggests a change to how the GWT AST is built that makes some operations easier:

// Force sub-parts to blocks, otherwise we break else-if chains.
// TODO: this goes away when we normalize the Java AST properly.
thenStmt = ensureBlock(thenStmt);
elseStmt = ensureBlock(elseStmt);

This should not impact JS at all, and a quick draft suggests that this will also be possible without changing the string representation of the GWT ast as well.

Since JIfStatement has no setters, the only way to rewrite its then/else statements is presently with a specialized visitor that only handles the top-level statement it finds. By implementing this change, we can also add/remove statements in either branch by just modifying the block's contents.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions