Bug 69141 - [1.5] Wildcards with lower bound do not work
Summary: [1.5] Wildcards with lower bound do not work
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 (vote)
Target Milestone: 3.1 M1   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-07-01 11:08 EDT by Samuel Kerschbaumer CLA
Modified: 2006-04-14 05:04 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Samuel Kerschbaumer CLA 2004-07-01 11:08:46 EDT
Consider the following code fragment:

		ArrayList<? super Integer> al = new ArrayList<Object>();
		al.add(new Integer(1)); // (1)
		Integer i = al.get(0);  // (2)

(1) gives you a compiler error. This is not correct because the list al contains 
elements of an unknown type, but the type must be a superclass of Integer
Therefore its completely legal to add an Integer

(2) compiles, but is not legal. The list can contain any type, so a cast to 
Integer is not save!



Using Eclipse 3.0M9 with Cheetah 0.0.6
Comment 1 Philipe Mulet CLA 2004-07-05 07:13:57 EDT
Lower bound check was indeed not properly implemented. Now tolerates 
invocation of method/constructor when parameter type is a wildcard with lower 
bound (similar evolution for assignment).

Also tuned the compatibility check for lower bounded wildcard to only use 
upper bound (i.e. variable) instead of considering bound.

Added regression tests: GenericTypeTest#test220-222.
Comment 2 Philipe Mulet CLA 2004-07-05 07:14:26 EDT
Fixed
Comment 3 Frederic Fusier CLA 2006-04-14 05:04:57 EDT
Verified for 3.1 using build I20050627-1435.