This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 172346

Summary: [Use Supertype] Where Possible refactoring leads to a compilation error when applied to a class in a complex class hierarcy
Product: java Reporter: vilasshekharbj <vilasshekharbj>
Component: RefactoringAssignee: Ralph Ruijs <ralphbenjamin>
Status: RESOLVED DUPLICATE    
Severity: blocker    
Priority: P3    
Version: 6.x   
Hardware: PC   
OS: Linux   
Issue Type: DEFECT Exception Reporter:

Description vilasshekharbj 2009-09-16 03:20:06 UTC
Apply the Use Super Type Where Possible refactoring to class A in the following code and choose class C as the super
type to be used:

interface B {
  public B m();
}
interface C {
  public C m();
}
class A implements C, B {
  public A m(){
    A a=null;
    return a;
  }
}

The refactoring correctly decides not to change the return type of A.m(), but incorrectly changes the type of A.m().a to
C without detecting that it is being returned and should be the same type as A.m(). This leads to the following code
that does not compile:

interface B {
  public B m();
}
interface C {
  public C m();
}
class A implements C, B {
  public A m(){
    C a=null;
    return a;
  }
}
Comment 1 Jan Pokorsky 2009-09-17 17:00:12 UTC
Thank you for the report. It is reproducible.
Comment 2 Jan Becicka 2011-08-02 08:41:58 UTC
another use supertype. thanks.
Comment 3 Ralph Ruijs 2011-09-08 10:02:33 UTC

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