Bug 34997 Inline method introduces spurious local variables [refactoring]
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
org.eclipse.jdt.ui.tests.refactoring/resources/InlineMethodWorkspace/TestCases/Test.java
public class Test {
	public void foo() {
		class Inner {
			void main() {
				bar();
				
				bar();
			}
			void bar() {
				System.out.println("Eclipse");
			}
		}
	}
}