Community
Participate
Working Groups
Bugzilla – Bug 357998
[extract interface] Extract interface incorrectly handles generics + interfaces
Last modified: 2011-10-24 14:34:40 EDT
Build Identifier: I20110613-1736 Extract interface with the option to use the extracted interface where possible will produce uncompilable code and also does not handle generics. public class Concrete { public int a; public int b; public int getA() { return a; } public Concrete(int a, int b) { super(); this.a = a; this.b = b; } public void setA(int a) { this.a = a; } public int getB() { return b; } public void setB(int b) { this.b = b; } } public interface IGeneric<V,T> { V getKey(); T getValue(); } public class Impl implements IConrete { @Override public String getKey() { // TODO Auto-generated method stub return null; } @Override public Concrete getValue() { List<Concrete> list = new ArrayList<Concrete>(); return list.get(0); } } public interface IConcrete extends IGeneric<String,Concrete> { } Extracting interface from Concrete to ISomeInterface will generate: public class Impl implements IConcrete { @Override public String getKey() { // TODO Auto-generated method stub return null; } @Override public ISomeInterface getValue() /* COMPILER ERROR. IConcrete was not refactored so the return type of getValue() is incorrect */ { /*Missed opportunity to refactor type of List<Concrete> */ List<Concrete> list = new ArrayList<Concrete>(); return list.get(0); } } Reproducible: Always Steps to Reproduce: See description
Can reproduce with 3.8 build I20111021-0800. As for updating the list: /*Missed opportunity to refactor type of List<Concrete> */ List<Concrete> list = new ArrayList<Concrete>(); see bug 107192.