Project: JDT
Bug 34997 Inline method introduces spurious local variables [refactoring]
Reported: 2003-03-14 01:12:32 | Status: resolved fixed

Version of Eclipse: Build id: 200303071024 (rc2), although the bug seems to have been there at least since m3 or so. Take the enclosed file, click on "inlineMe", and then select Refactor/Inline. The resulting version of the caller method will look like this: public void caller(Writer out) throws Exception { out.write("start caller"); Writer out1 = out; out1.write("start render"); subroutine(true, out1); out1.write("end render"); out.write("end caller"); } The variable "out1" is not needed, and in fact in slight variations of this test case, Eclipse will just use out instead of introducing out1 (using out is the correct behavior). ----- start test case InlineBug.java import java.io.Writer; public class InlineBug { public void caller(Writer out) throws Exception { out.write("start caller"); inlineMe(out); out.write("end caller"); } public void inlineMe(Writer out) throws Exception { out.write("start render"); subroutine(true, out); out.write("end render"); } void subroutine(boolean isSelected, Writer out) throws Exception { if (isSelected) { out.write("selected"); } } } ----- end test case InlineBug.java

Files changed in fix:
org.eclipse.jdt.ui.tests.refactoring/resources/InlineMethodWorkspace/TestCases/InlineBug.java org.eclipse.jdt.ui.tests.refactoring/resources/InlineMethodWorkspace/TestCases/Test.java org.eclipse.jdt.ui.tests.refactoring/resources/InlineMethodWorkspace/TestCases/argument_in/TestFieldReference.java org.eclipse.jdt.ui.tests.refactoring/resources/InlineMethodWorkspace/TestCases/argument_in/TestLocalReferencePrefix.java org.eclipse.jdt.ui.tests.refactoring/resources/InlineMethodWorkspace/TestCases/argument_out/TestFieldReference.java org.eclipse.jdt.ui.tests.refactoring/resources/InlineMethodWorkspace/TestCases/argument_out/TestLocalReferencePrefix.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/ParameterData.java org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/SourceAnalyzer.java org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/flow/FlowAnalyzer.java org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/flow/FlowContext.java org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/flow/FlowInfo.java