Bug 292981 - [push down] Push down method refactoring changes the program behavior
Summary: [push down] Push down method refactoring changes the program behavior
Status: CLOSED DUPLICATE of bug 234981
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.4.2   Edit
Hardware: PC Linux
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 355322 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-10-21 22:15 EDT by Gustavo Soares CLA
Modified: 2011-10-24 15:33 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gustavo Soares CLA 2009-10-21 22:15:12 EDT
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 a push down method refactoring is applied on a method "m", and there is a
method invocation to a method of the superclass inside "m".  The method
invocation changes to a method of the subclass with a different signature. 


Reproducible: Always

Steps to Reproduce:
1. Create the classes:

public class A {
	public int k(long i) {return 79;}
}

public class B extends A {
	public int k(int i) {return 83;	}

	public int m() {return super.k(2);}
}

public class C extends B {	
	public static void main(String[] args) {
		C c = new C();
		System.out.println(c.m());
	}
}

2. This program prints 79. Apply a push down method refactoring on m(). The
program will be transformed:

public class A {
	public int k(long i) {return 79;}
}

public class B extends A {
	public int k(int i) {return 83;	}	
}

public class C extends B {	
	public static void main(String[] args) {
		C c = new C();
		System.out.println(c.m());
	}

        public int m() {return super.k(2);}
}

3. Note that After the refactoring, the "super.k(2);" invocation is to the method "int m(int i)" instead of "int m(long i)". the behavior of the program changes, now, it will be printed 83
Comment 1 Dani Megert CLA 2009-10-22 03:17:52 EDT
Can reproduce in I20091020-0931.
Same problem like in bug 234981 but a but more complext.

*** This bug has been marked as a duplicate of bug 234981 ***
Comment 2 Raksha Vasisht CLA 2011-10-24 15:33:49 EDT
*** Bug 355322 has been marked as a duplicate of this bug. ***