Bug 357998 - [extract interface] Extract interface incorrectly handles generics + interfaces
[extract interface] Extract interface incorrectly handles generics + interfaces
Status: ASSIGNED
Product: JDT
Classification: Eclipse
Component: UI
3.7
All All
: P3 normal with 1 vote (vote)
: ---
Assigned To: JDT-UI-Inbox CLA Friend
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2011-09-17 05:33 EDT by Yuli CLA Friend
Modified: 2011-10-24 14:34 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Yuli CLA Friend 2011-09-17 05:33:30 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
Comment 1 Raksha Vasisht CLA Friend 2011-10-24 14:34:40 EDT
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.