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

Bug 356684

Summary: [push down] changes behavior due to declaration shadowing
Product: [Eclipse Project] JDT Reporter: Gustavo Soares <gsoares>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: CLOSED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: markus.kell.r
Version: 3.8   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Gustavo Soares CLA 2011-09-04 15:24:52 EDT
Build Identifier: 20110615-0604

Pushing down a method to a class in another package may shadow a Class declaration leading to a behavioral change 

Reproducible: Always

Steps to Reproduce:
1. Create the classes
package p2;
public class B extends A {
}
package p1;
import p2.*;
public class B extends A {
  protected long k(  int a){
    return 0;
  }
  public long test(){
    return m();
  }
}
package p2;
import p1.*;
public class A {
  public long k(  long a){
    return 1;
  }
  public long m(){
    return new B().k(2);
  }
}
2. Apply the push down method to m()
package p1;
import p2.*;
public class B extends A {
  protected long k(  int a){
    return 0;
  }
  public long test(){
    return m();
  }
public long m() {
    return new B().k(2);
  }
}
package p2;
public class B extends A {
	public long m() {
	    return new B().k(2);
	  }
}
package p2;
import p1.*;
public class A {
  public long k(  long a){
    return 1;
  }
}
3. Before the transformation, method m() yields 1, but after that, it yields 0.
Comment 1 Markus Keller CLA 2011-09-05 12:21:30 EDT

*** This bug has been marked as a duplicate of bug 211755 ***