| Summary: | [pull up] Pull up refactoring changes the program behavior | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Gustavo Soares <gsoares> |
| Component: | UI | Assignee: | JDT-UI-Inbox <jdt-ui-inbox> |
| Status: | CLOSED DUPLICATE | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | daniel_megert |
| Version: | 3.6 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Linux | ||
| Whiteboard: | |||
*** This bug has been marked as a duplicate of bug 234980 *** |
User-Agent: Mozilla/5.0 (X11; U; Linux i686; pt-BR; rv:1.9.0.14) Gecko/2009090216 Ubuntu/9.04 (jaunty) Firefox/3.0.14 GTB5 Build Identifier: M20090211-1700 When is applied a pull up refactoring on a method that calls another using the "super", the engine change the "super" for "this". This can change the behavior of the code if the child of the subclass contains a method with the same signature of the called method. Reproducible: Always Steps to Reproduce: 1. Create the classes: public class A { public int k(){return 79;} } public class B extends A { public int m() {return super.k();} } public class C extends B{ public int k() {return 83;} public static void main(String[] args) { System.out.println(new C().m()); } } 2. This program prints 79. Apply a pull up method refactoring on m(). The program will be transformed: public class A { public int k(){return 79;} public int m() {return this.k();} } public class B extends A { } public class C extends B{ public int k() {return 83;} public static void main(String[] args) { System.out.println(new C().m()); } } 3. The refactoring engine changes the "super" for "this", but the "this" is resolved at run-time. So, after the refactoring, the behavior of the program changes, now, it will be printed 83