Project: JDT
Bug 47798 convert local variable to field gives erroneous error [refactoring]
Reported: 2003-12-01 09:00:44 | Status: resolved fixed

perform the "convert local variable to field" refactoring on the variable x and select "initialize in field declaration" and the "make final" options on the text below: --------------------------------------------------- public class Test { public static void method2(final int i) { final I x = new I()//<-- refactor->convert local variable x to field { public void methodI() { int y = 3; } }; } } interface I { void methodI(); } ---------------------------------------------------------------- gives the error message: Cannot promote this local variable to a field because it uses types or variables declared locally in this method. Which is clearly wrong!

Files changed in fix:
org.eclipse.jdt.ui.tests.refactoring/resources/PromoteTempToField/canPromote/A_test21_in.java org.eclipse.jdt.ui.tests.refactoring/resources/PromoteTempToField/canPromote/A_test21_out.java org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/PromoteTempToFieldTests.java org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/PromoteTempToFieldRefactoring.java