Bug 53851 extract method in anonymous class introduces error [refactoring]
Test case: public class Bug { void test () { new Object () { public void yes () { System.out.println ("hello world"); } }; System.out.println ("hello world"); } } Three (possibly related) problems: 1. Select the first print statement (whole line). Refactor:Extract Method..., enter some name and press OK, leaving "replace 1 duplicate code fragment" checked. The method is created inside the anonymous class but called from outside. 2. Select the second print statement (whole line). Refactor:Extract Method... The duplicate code fragment is not recognized. 3. Select only "println" in either print statement. Refactor:Extract Method..., enter some name and press OK. You get a strange error message: "Cannot determine expression's return type. Using void instead." Pressing Continue produces meaningless code.
org.eclipse.jdt.ui.tests.refactoring/resources/ExtractMethodWorkSpace/ExtractMethodTests/duplicates_out/A_test962.java
package duplicates_out;
public class A_test962 {
	private Object object;
	public A_test962() {
	  this.object = new Object();
	  System.out.println(extracted());
	}
	protected Object extracted() {
		return this.object;
	}
}