Community
Participate
Working Groups
Build ID: I20080617-2000 Steps To Reproduce: Use Extract Method on 'foo' in the indicated line. class Bar { boolean foo; private boolean getFoo() { return foo; // use 'Extract Method' on 'foo' here } private void setFoo(boolean newFoo) { this.foo = newFoo; // breaks this line } } More information: This changes the indicated line in setFoo to: this.bar() = foo; which is obviously incorrect. If the assignment to foo is changed to 'foo = newFoo' (i.e. without 'this.'), the problem disappears.
Benny, could you please have a look? Note that it's broken for all FieldAccess expressions used as assignment targets where the 'name' property matches the expression, e.g.: class Bar { Bar other; boolean foo; private boolean getFoo() { return foo; // use 'Extract Method' on 'foo' here } private void setFoo(boolean newFoo) { this.foo = newFoo; // breaks this line other.foo = newFoo; // breaks this line as well } }
Created attachment 143199 [details] patch+testcases Here we go :-)
Comment on attachment 143199 [details] patch+testcases The patch breaks cases where the field to be extracted is on the left hand side but as a qualifier, e.g. if you add this to the example from comment 1 and then try to extract 'other': other.foo = newFoo; other.other.foo = newFoo;
Created attachment 145356 [details] updated patch+testcases Markus, here is an updated version of the patch + an additional testcase for the mentioned problem.
Thanks, released to HEAD.