Bug 73963

Summary: [1.5] Wrong errors in widening reference conversion to parameterized class type
Product: [Eclipse Project] JDT Reporter: Markus Keller <markus.kell.r>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: evol, joe.bowbeer
Version: 3.0   
Target Milestone: 3.1 M3   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Markus Keller CLA 2004-09-15 04:13:14 EDT
I200409140800
In the following code, I get 2 errors which I think are both wrong:

void takeAbstract(AbstractList<? extends InetAddress> arg) { }

void takeList(List<? extends InetAddress> arg) { }

void construct() {
	AbstractList<InetAddress> a= new ArrayList<InetAddress>();
	takeAbstract(a);
	takeAbstract(new ArrayList<InetAddress>()); // a inlined: error 1:
//The method takeAbstract(AbstractList<? extends InetAddress>) in the type A
// is not applicable for the arguments (ArrayList<InetAddress>)
	
	List<InetAddress> l= new ArrayList<InetAddress>();
	takeList(l);
	takeList(new ArrayList<InetAddress>()); // l inlined: ok
	
	ArrayList<? extends InetAddress> aw= new ArrayList<InetAddress>();
	takeAbstract(aw);
	takeAbstract(new ArrayList<Inet6Address>()); // aw inlined: error 2:
//The method takeAbstract(AbstractList<? extends InetAddress>) in the type A
// is not applicable for the arguments (ArrayList<Inet6Address>)

	takeList(aw);
	takeList(new ArrayList<Inet6Address>()); //aw inlined: ok
}
Comment 1 Kent Johnson CLA 2004-09-23 17:21:14 EDT
Should consider changing ReferenceBinding.isSuperclassOf() to:

public boolean isSuperclassOf(ReferenceBinding otherType) {
	while ((otherType = otherType.superclass()) != null) {
		if (otherType.isEquivalentTo(this)) return true;
	}
	return false;
}

This maintains the order of receiver vs. otherType for calls to isEquivalentTo
().

We pass all of our GenericTypeTests with this change.
Comment 2 Philipe Mulet CLA 2004-10-01 13:25:30 EDT
Indeed this fixes the problem.
Added regression GenericTypeTest#test313.

Fixed
Comment 3 Philipe Mulet CLA 2004-10-21 08:04:37 EDT
*** Bug 76729 has been marked as a duplicate of this bug. ***
Comment 4 Philipe Mulet CLA 2004-10-27 04:14:38 EDT
*** Bug 77078 has been marked as a duplicate of this bug. ***
Comment 5 David Audel CLA 2004-11-04 07:11:16 EST
Verified for 3.1M3 with build I200411040100