Project: JDT
Bug 169331 [inline] else branch captured after method inlining
Reported: 2007-01-02 08:58:10 | Status: resolved fixed

Build ID: M20060921-0945 Consider the code snippet void a(boolean x) { if( x ) System.out.println("in a: x is true"); } void b(boolean x, boolean y) { if( y ) a(x); else System.out.println("in b: y is false"); } When I use the "inline" refactorization on a(boolean) I end up with void b(boolean x, boolean y) { if( y ) if( x ) System.out.println("in a: x is true"); else System.out.println("in b: y is false"); } which has the wrong semantics; it parses as void b(boolean x, boolean y) { if( y ) { if( x ) System.out.println("in a: x is true"); else System.out.println("in b: y is false"); } } The refactorization should insert a level of braces in such cases to prevent the else being captured.

Files changed in fix:
org.eclipse.jdt.ui.tests.refactoring/resources/InlineMethodWorkspace/TestCases/controlStatement_in/TestDanglingIf.java org.eclipse.jdt.ui.tests.refactoring/resources/InlineMethodWorkspace/TestCases/controlStatement_out/TestDanglingIf.java org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineMethodTests.java org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/CallInliner.java org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/SourceProvider.java