Bug 114997 - [1.5][compiler] type mismatch with Collections.emptyList and wildcard
Summary: [1.5][compiler] type mismatch with Collections.emptyList and wildcard
Status: VERIFIED DUPLICATE of bug 112268
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1.2   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-11-03 16:57 EST by Andrew Bachmann CLA
Modified: 2006-01-10 09:59 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 Andrew Bachmann CLA 2005-11-03 16:57:28 EST
The following code generates an error in eclipse 3.1.1 and 3.1m2, but it
compiles fine in both eclipse 3.1 and javac version 1.5.0_05.  It doesn't matter
if the "Interface" class below is defined as a class or as an interface, it
generates the error in both cases.  The error is:
 "Type mismatch: cannot convert from List<Object> to List<? extends Test.Interface>"

import java.util.Collections;
import java.util.List;

public class Test {
  public interface Interface {
	  // nothing
  }
  public List<? extends Interface> field = Collections.emptyList();
}
Comment 1 Andrew Bachmann CLA 2005-11-03 17:02:59 EST
A workaround that doesn't involve suppressing warnings is to explicitly supply
the extended type:

  public List<? extends Interface> field = Collections.<Interface>emptyList();
Comment 2 Philipe Mulet CLA 2005-11-03 18:02:38 EST
A patch for 3.1.1 is available, see some comment in bug 112268.
Added regression test: GenericTypeTest#test866

*** This bug has been marked as a duplicate of 112268 ***
Comment 3 Olivier Thomann CLA 2006-01-10 09:59:43 EST
Verified in M20060109-0800 for 3.1.2