Bug 76434

Summary: [1.5] Generics, assign error despite equal types
Product: [Eclipse Project] JDT Reporter: Heri <eclipse>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 3.1   
Target Milestone: 3.1 M3   
Hardware: PC   
OS: Windows XP   
Whiteboard:

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.