Bug 209152 - [1.5][compiler] different captures for the the same wildcard
Summary: [1.5][compiler] different captures for the the same wildcard
Status: VERIFIED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.4 M4   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-11-08 05:13 EST by Tobias Riemenschneider CLA
Modified: 2007-12-11 07:31 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 Tobias Riemenschneider CLA 2007-11-08 05:13:06 EST
Build ID: M20071023-1652

Steps To Reproduce:
1. Simply compile the following piece of sourcecode.

> Test.java >>>
import java.util.List;

public class Test {
	public static void doIt(List<?> list) {
		list.add(list.remove(0));
	}
}
< Test.java <<<

2. The resulting compiler message should be
###
Severity and Description	Path	Resource	Location	Creation Time	Id
The method add(capture#1-of ?) in the type List<capture#1-of ?> is not applicable for the arguments (capture#2-of ?)	@workspace/src	Test.java	line 5	1194516108823	1446564
###


More information:
Why are there different captures of the specified wildcard. The wildcard should be captured only once and this capture should be used for the parameter type of the add method as well as the return type of the remove method (both parameters are specified by the generic type E in interface List). By capturing the wildcard, it is arbitrary but fixed, i.e., every usage of the underlying generic type E should use the same capture of the wildcard.
Comment 1 Philipe Mulet CLA 2007-11-15 07:05:34 EST
Unfortunately no. The spec is very clear about it. Each reference to a wildcard is captured independantly, and produces distinct types; hence the error message you get.

You may be interesting in reading: http://blogs.sun.com/ahe/date/20040610

Closing as INVALID
Comment 2 Philipe Mulet CLA 2007-11-15 07:11:19 EST
Added GenericTypeTest#test1220
Comment 3 Frederic Fusier CLA 2007-12-11 07:31:49 EST
Verified for 3.4M4