void () { boolean foo = true; boolean bar = true; if(foo) { System.out.println("1"); } else if(bar) { System.out.println("1"); } else { System.out.println("2"); } // test that these don't merge if(foo) { System.out.println("1"); } else if(bar) { System.out.println("3"); } else { System.out.println("2"); } // test that these don't merge if(foo) { System.out.println("1"); } else if(bar) { } else { System.out.println("2"); } if(foo) { System.out.println("2"); return; } if(bar) { System.out.println("2"); return; } if(foo) { System.out.println("1"); return; } if(bar) { System.out.println("1"); return; } else { System.out.println("2"); } }