Bug 95774 - [5.0] Invalid capture-related compiler problem when generating delegate
Summary: [5.0] Invalid capture-related compiler problem when generating delegate
Status: RESOLVED WORKSFORME
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 RC3   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-05-18 11:01 EDT by Tobias Widmer CLA
Modified: 2005-06-15 15:14 EDT (History)
0 users

See Also:


Attachments
workspace preferences (248.95 KB, text/plain)
2005-05-18 11:03 EDT, Tobias Widmer CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Widmer CLA 2005-05-18 11:01:56 EDT
N20050518-0010:

Steps to reproduce:
- Create simple Java project using workspace settings
- Create cu
import java.util.Collection;

public class Test {
	Collection<String> c;

	public Test() {
		super();
	}
}

- Invoke 'Generate Delegate Method', select only addAll
- Generate delegate results in

	public boolean addAll(Collection<? extends String> c) {
		return c.addAll(c);
	}

-> Compile error

The method addAll(Collection<? extends capture-of ? extends String>) in the 
type 
 Collection<capture-of ? extends String> is not applicable for the arguments 
(Collection<capture-of 
 ? extends String>)

although the generated code is correct

Attaching workspace preferences
Comment 1 Tobias Widmer CLA 2005-05-18 11:03:11 EDT
Created attachment 21337 [details]
workspace preferences
Comment 2 David Pickens CLA 2005-06-15 14:27:56 EDT
I also encountered a similar error when moving up from 3.1M6 to 3.1RC2. I have
several source files that no longer compile. Here is a simple test case that
demonstrates the problem:

import java.util.ArrayList;
import java.util.List;
public class Test {
    void foo() {
        List<? extends Number> s = new ArrayList<Number>();
        List<? extends Number> t = new ArrayList<Number>();
        s.addAll(t);  // <-- Generates bogus error message
    }
}
Comment 3 Philipe Mulet CLA 2005-06-15 15:11:29 EDT
javac agrees with us on latter case:
Test.java:7: cannot find symbol
symbol  : method addAll(java.util.List<capture of ? extends java.lang.Number>)
location: interface java.util.List<capture of ? extends java.lang.Number>
        s.addAll(t);  // <-- Generates bogus error message
         ^
1 error

Basically, captures exhibits the fact that a wildcard denotes 'some' type, but
not any type. See litterature on wildcards or JLS 3rd edition for more details.


Comment 4 Philipe Mulet CLA 2005-06-15 15:14:26 EDT
I cannot reproduce original issue with latest.
Closing, pls reopen if you still see a problem.