leibnitz27 / cfr

This is the public repository for the CFR Java decompiler
https://www.benf.org/other/cfr
MIT License
2.01k stars 258 forks source link

Failed to decompile nested conditions #222

Closed nitram84 closed 3 years ago

nitram84 commented 3 years ago

CFR version

CFR 0.151-SNAPSHOT (dfdb9d5) and CFR 0.150, so this is not a regression of recent changes

Compiler

openjdk8, openjdk11

Description

Nested conditions could not be decompiled in some cases:

Example

public class CFRTest1 {

  public int checkConditions(boolean a, boolean b, boolean c) {
    if (a) {
      if (b) {
        doSomething();
      } else {
        if (c) {
          doSomething();
          return 1;
        } else {
          doSomething();
          return 0;
        }
      }
    } else {
      doSomething();
    }
    doSomething();
    return 2;
  }

  private void doSomething() {
  }
}

This example can be used for the cfr test suite.

leibnitz27 commented 3 years ago

Hm - the fix is clean enough but does highlight that (hah, like your last issue) I can be a bit keen to use anonymous blocks. I think a few more transforms to reduce these, when I get a chance \o/