Project: JDT
Bug 24931 inline method - adds unnecessary assignment [refactoring]
Reported: 2002-10-17 07:49:09 | Status: resolved fixed

I-20021016 linux-gtk: public class Moo { void foo(int a) { System.out.println(a); } void goo() { int n= 42; foo(n); int x= 7; // <-- } } 1. select foo in goo 2. inline method 3. press next 4. observe that the method invocation 'foo(n);' is replaced by 'int a= n; System.out.println(a);' This assignment is unnecessary und will go away if the following unrelated statement ('int x= 7;') is removed. I assume this is some sort of conservative strategy to avoid variable name clashes.

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