Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/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 QA Contact: issues <issues.netbeans.org>
Priority: P3    
Version: 6.x   
Target Milestone: 7.1   
Hardware: PC   
OS: Linux   
Whiteboard:
Issue Type: DEFECT Exception Report:

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 ***
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo