Bug 76434 - [1.5] Generics, assign error despite equal types
Summary: [1.5] Generics, assign error despite equal types
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal with 1 vote (vote)
Target Milestone: 3.1 M3   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-10-16 21:56 EDT by Heri CLA
Modified: 2005-01-03 09:41 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 Heri CLA 2004-10-16 21:56:00 EDT
Build 200410130800

I get the following compile error:

Type mismatch: cannot convert from Set<Map.Entry<Integer,?>> to
Set<Map.Entry<Integer,?>>

with this class:

public class Test 
{
  private Set<Map.Entry<Integer, ?>> m_values;
  
  Test(Map<Integer, ?> values)
  {
    m_values = values.entrySet();
  }
}
Comment 1 Guillaume Pothier CLA 2004-10-27 22:34:04 EDT
I've had several of these errors with M2 and latest integration build (I20041026).
I have been able to use a cast as a workaround. Interestingly enough, the
compiler reports a warning about useless cast.
It never happened with "top-level" generics, bu only with "nested" generics, ie.
X<A<B>>.
Comment 2 Guillaume Pothier CLA 2004-10-27 22:36:43 EDT
Thinking about it, it might have to do with inner classes.
Comment 3 Philipe Mulet CLA 2004-10-29 09:54:12 EDT
Reproduced
Comment 4 Philipe Mulet CLA 2004-10-29 10:24:12 EDT
Problem comes from a mismatch in wildcards, due to capture mechanism.
We are comparing 
    Set<Map.Entry<Integer, ? denoting: V from Map) 
with 
    Set<Map.Entry<Integer, ? denoting: V from Map$Entry)
Comment 5 Philipe Mulet CLA 2004-11-02 10:48:31 EST
Ensured wildcards are properly relocated when passed around.
Added regression test: GenericTypeTest#test363
Fixed
Comment 6 Frederic Fusier CLA 2004-11-04 11:41:44 EST
Verified for 3.1 M3 with build I200411040800
Comment 7 Philipe Mulet CLA 2005-01-03 09:41:35 EST
Actually, reverting previous behavior which was the proper one. 
Javac does actually also reject this code.

The 2 wildcard occurrences could denote different types. One is relative to
Entry, and one is relative to Map; as said before.