IDEA-172200 Decompiler switch-on-enum multiple switches in same class generates wrong cases for all but the first switch-on-enum

This commit is contained in:
Egor.Ushakov
2017-05-05 13:10:53 +03:00
parent bbc76e7cb4
commit 17d4894848
8 changed files with 91 additions and 2 deletions

View File

@@ -37,8 +37,9 @@ public class SwitchHelper {
List<List<Exprent>> caseValues = switchStatement.getCaseValues();
Map<Exprent, Exprent> mapping = new HashMap<>(caseValues.size());
ArrayExprent array = (ArrayExprent)value;
FieldExprent arrayField = (FieldExprent)array.getArray();
ClassesProcessor.ClassNode classNode =
DecompilerContext.getClassProcessor().getMapRootClasses().get(((FieldExprent)array.getArray()).getClassname());
DecompilerContext.getClassProcessor().getMapRootClasses().get(arrayField.getClassname());
if (classNode != null) {
MethodWrapper wrapper = classNode.getWrapper().getMethodWrapper(CodeConstants.CLINIT_NAME, "()V");
if (wrapper != null) {
@@ -48,7 +49,7 @@ public class SwitchHelper {
if (exprent instanceof AssignmentExprent) {
AssignmentExprent assignment = (AssignmentExprent)exprent;
Exprent left = assignment.getLeft();
if (isEnumArray(left)) {
if (left.type == Exprent.EXPRENT_ARRAY && ((ArrayExprent)left).getArray().equals(arrayField)) {
mapping.put(assignment.getRight(), ((InvocationExprent)((ArrayExprent)left).getIndex()).getInstance());
}
}