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

Bug 357998

Summary: [extract interface] Extract interface incorrectly handles generics + interfaces
Product: [Eclipse Project] JDT Reporter: Yuli <fiterman>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: deepakazad, markus.kell.r, raksha.vasisht
Version: 3.7   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard: stalebug

Description Yuli CLA 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 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.
Comment 2 Eclipse Genie CLA 2020-03-03 17:19:09 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.