fix: fix default branch position in switch-over-string (PR #2331)

This commit is contained in:
pubiqq
2024-10-31 22:58:35 +03:00
committed by GitHub
parent 2661b91a6f
commit cfbe5ab672
3 changed files with 24 additions and 1 deletions
@@ -103,10 +103,10 @@ public class SwitchOverStringVisitor extends AbstractVisitor implements IRegionI
// all checks passed, replace with new switch
IRegion parentRegion = switchRegion.getParent();
SwitchRegion replaceRegion = new SwitchRegion(parentRegion, switchRegion.getHeader());
replaceRegion.addDefaultCase(switchData.getDefaultCode());
for (CaseData caseData : switchData.getCases()) {
replaceRegion.addCase(Collections.unmodifiableList(caseData.getStrValues()), caseData.getCode());
}
replaceRegion.addDefaultCase(switchData.getDefaultCode());
if (!parentRegion.replaceSubBlock(switchRegion, replaceRegion)) {
mth.addWarnComment("Failed to restore switch over string. Please report as a decompilation issue");
return false;