Bug 121231

Summary: [1.5][compiler] Valid generic use causes type mismatch error
Product: [Eclipse Project] JDT Reporter: Jim Elliott <jim>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: VERIFIED DUPLICATE QA Contact:
Severity: major    
Priority: P3    
Version: 3.1.1   
Target Milestone: 3.1.2   
Hardware: PC   
OS: Windows XP   
Whiteboard:

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