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

Bug 448894

Summary: [move method] incorrect variable name which references the original class
Product: [Eclipse Project] JDT Reporter: Jongwook Kim <jongwook.kim>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: jongwook.kim, markus.kell.r
Version: 4.4.1   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard: stalebug

Description Jongwook Kim CLA 2014-10-26 15:21:47 EDT
When move-instance-method is applied, JDT adds a new parameter to reference members in the original class. The parameter is named incorrectly.

//-------------------------------------------------------------------
//BEFORE
//-------------------------------------------------------------------
class A {
	int i = 0;

	void m(B b) {
		b.a = new A();
		i++;
	}
}

class B {
	A a = null;
}

//-------------------------------------------------------------------
//AFTER
//-------------------------------------------------------------------
class A {
	int i = 0;
}

class B {
	A a = null;

	void m(A a) {           // BUG: capturing field 'a'
		a = new A();    // value of field 'a' is not updated.
		a.i++;
	}
}
Comment 1 Eclipse Genie CLA 2019-12-18 19:40:10 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.