Bug 73963 - [1.5] Wrong errors in widening reference conversion to parameterized class type
Summary: [1.5] Wrong errors in widening reference conversion to parameterized class type
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 normal with 1 vote (vote)
Target Milestone: 3.1 M3   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 76729 77078 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-09-15 04:13 EDT by Markus Keller CLA
Modified: 2004-11-04 07:11 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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