Project: JDT
Bug 318127 [extract method] "Extract Method" into an enclosing class fails when the inner class has a method of the same name
Reported: 2010-06-27 10:57:06 | Status: verified fixed

Build Identifier: 20100218-1602 When using "Extract Method" on an expression in an inner class to extract it into a method in the enclosing class, and the name of the new method is the same as the name of some method of the inner class, the refactoring fails although there is no name clash. Reproducible: Always Steps to Reproduce: 1. package sandbox; import java.util.HashSet; import java.util.Set; public class A { private class B { private void g() {} private int f() { return 2 + 3; } } } 2. Use Extract Method on the expression "2 + 3" choosing the function name g and destination type A. 3. The refactoring fails with message "Method 'g' already exists in type 'B'."

Files changed in fix:
org.eclipse.jdt.ui.tests.refactoring/resources/ExtractMethodWorkSpace/ExtractMethodTests/destination_in/A_test1054.java org.eclipse.jdt.ui.tests.refactoring/resources/ExtractMethodWorkSpace/ExtractMethodTests/destination_in/A_test1055.java org.eclipse.jdt.ui.tests.refactoring/resources/ExtractMethodWorkSpace/ExtractMethodTests/destination_in/A_test1056.java org.eclipse.jdt.ui.tests.refactoring/resources/ExtractMethodWorkSpace/ExtractMethodTests/destination_in/A_test1057.java org.eclipse.jdt.ui.tests.refactoring/resources/ExtractMethodWorkSpace/ExtractMethodTests/destination_out/A_test1054.java org.eclipse.jdt.ui.tests.refactoring/resources/ExtractMethodWorkSpace/ExtractMethodTests/destination_out/A_test1055.java org.eclipse.jdt.ui.tests.refactoring/resources/ExtractMethodWorkSpace/ExtractMethodTests/destination_out/A_test1056.java org.eclipse.jdt.ui.tests.refactoring/resources/ExtractMethodWorkSpace/ExtractMethodTests/destination_out/A_test1057.java org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractMethodTests.java org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ExtractMethodAnalyzer.java org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ExtractMethodRefactoring.java