| Summary: | [refactoring][move method] Code is broken when moving a method that is assigning to the parameter that is also the move destination. | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Erlend Kristiansen <erlend.k> |
| Component: | UI | Assignee: | JDT-UI-Inbox <jdt-ui-inbox> |
| Status: | CLOSED WONTFIX | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | jongwook.kim, markus.kell.r, stolz+bugzilla |
| Version: | 4.3.1 | ||
| Target Milestone: | --- | ||
| Hardware: | All | ||
| OS: | All | ||
| Whiteboard: | stalebug | ||
Yes, we already detect the same problem when trying to move to a field that is assigned:
public class A {
B b;
void methodToMove() {
b = new B();
}
}
We should have the same test for parameters as well.
The error message could also use some love:
> In addition the target must be writable.
Should be something like:
In addition, replacing the target with 'this' must be legal.
*** Bug 424654 has been marked as a duplicate of this bug. *** 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. |
Build id: 20130919-0819 Steps to reproduce: 1. Make the classes A and B: public class A { void methodToMove(B b) { b = new B(); } } public class B { } 2. Perform Move Method refactoring on 'methodToMove' from A to B, with the following result: public class A { } public class B { void methodToMove() { this = new B(); // <-- bug! } } Bug: The method 'methodToMove' is now assigning to the 'this' keyword, which is not allowed in Java.