Bug 121231 - [1.5][compiler] Valid generic use causes type mismatch error
Summary: [1.5][compiler] Valid generic use causes type mismatch error
Status: VERIFIED DUPLICATE of bug 112500
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1.1   Edit
Hardware: PC Windows XP
: P3 major with 1 vote (vote)
Target Milestone: 3.1.2   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-12-16 11:38 EST by Jim Elliott CLA
Modified: 2006-01-10 10:00 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jim Elliott CLA 2005-12-16 11:38:37 EST
One of our developers upgraded from 3.1.0 to 3.1.1 and started complaining about syntax errors in some of our classes. They are valid, and compile fine with javac and Eclipse 3.1.0.

Here is a simplified example:

import java.util.Collection;
import java.util.Collections;

public class Example {
    public Collection<? extends Integer> getCollection() {
        return Collections.emptyList();
  }
}

This fails to compile in Eclipse 3.1.1. The return statement is flagged "Type mismatch: cannot convert from List<Object> to Collection<? extends Integer>" which is incorrect, because the emptyList() function in Java 5's Collections class is designed to return a list of whatever type is required of it.
Comment 1 Olivier Thomann CLA 2005-12-19 13:17:12 EST
This is fixed in the 3.1 maintenance stream.
You can use one of the latest maintenance stream to get the fix or you wait for the 3.1.2 release.
Closing as a duplicate of bug 112500.
Added regression test org.eclipse.jdt.core.tests.compiler.regression.GenericTypeTest.test871

*** This bug has been marked as a duplicate of 112500 ***
Comment 2 Olivier Thomann CLA 2006-01-10 10:00:44 EST
Verified in M20060109-0800 for 3.1.2