Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 335674

Summary: [extract method] wrong return type when extracting code from a cycle
Product: [Eclipse Project] JDT Reporter: kuba <kuba.v>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: CLOSED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: amj87.iitr, deepakazad, kuba.v
Version: 3.5.2   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description kuba CLA 2011-01-28 06:18:08 EST
Build Identifier: 20090920-1017

In the following snippet extracting the marked code (the body of the second cycle) would lead to:
extracted(multiple3, j);
instead of
multiple3 = extracted(multiple3, j);
There is no warning shown, but it changes the result!

--------------- code snippet -----------------

String multiple3 = "";

System.out.println("Searching numbers: ");
//this for cycle has to be here! If commented it works fine.
for (int t = 1; t < 20; t++) {
	System.out.print(t + ", ");
}

for (int j = 1; j < 20 ; j++) {
	//try to extract following 4 lines to a method
	if (j % 3 == 0) {
		multiple3 = multiple3 + j + ", ";
	}
	System.out.println(multiple3);
}

Reproducible: Always
Comment 1 Ayushman Jain CLA 2011-01-28 06:47:14 EST
Moving to JDT/UI for comment.
Comment 2 Deepak Azad CLA 2011-01-28 08:15:01 EST
This works with 3.6, can you please try with that.

*** This bug has been marked as a duplicate of bug 213519 ***