Skip to content

Fix not inlining cases with multiple switch expressions in a single line#564

Open
coehlrich wants to merge 4 commits into
Vineflower:develop/1.13.0from
coehlrich:fix-multiple-switch-expressions-in-one
Open

Fix not inlining cases with multiple switch expressions in a single line#564
coehlrich wants to merge 4 commits into
Vineflower:develop/1.13.0from
coehlrich:fix-multiple-switch-expressions-in-one

Conversation

@coehlrich
Copy link
Copy Markdown
Contributor

@coehlrich coehlrich commented Apr 15, 2026

Fixes cases like

    public int test(int i1, int i2) {
        return switch (i1) {
            case 0 -> 1;
            case 1 -> 0;
            default -> 0;
        } + switch (i2) {
            case 0 -> 1;
            case 1 -> 0;
            default -> 0;
        };
    }

decompiling to

    public int test(int i1, int i2) {
        byte var10000 = switch (i1) {
            case 0 -> 1;
            case 1 -> 0;
            default -> 0;
        };

        return var10000 + switch (i2) {
            case 0 -> 1;
            case 1 -> 0;
            default -> 0;
        };
    }

utafrali

This comment was marked as spam.

@jaskarth jaskarth added Type: Enhancement New feature or request Subsystem: Statement Structure Anything concerning how statements are structured in a method Priority: Medium Medium priority Subsystem: Variables Anything concerning variables, types, assignments, and casting labels Apr 15, 2026
Comment on lines +160 to +164
} else if (!root.containsStatement(nd.statement) && !(root instanceof RootStatement)) {
parentStack.add(nd);
parentStackMaps.add(new HashMap<>(currentParentStackMap));
continue;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this case

nd = ndsucc;

// Skip over phantom switch statements
if (ndsucc.statement instanceof SwitchStatement switchSt && switchSt.isPhantom()) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand what is going on here :[

@coehlrich coehlrich changed the base branch from develop/1.12.0 to develop/1.13.0 May 11, 2026 10:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Priority: Medium Medium priority Subsystem: Statement Structure Anything concerning how statements are structured in a method Subsystem: Variables Anything concerning variables, types, assignments, and casting Type: Enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants