Bug 205594 - [1.5][compiler] False compiler error
Summary: [1.5][compiler] False compiler error
Status: VERIFIED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.4 M3   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-10-05 13:11 EDT by Mike M CLA
Modified: 2007-10-29 05:20 EDT (History)
2 users (show)

See Also:


Attachments
Code to reproduce (299 bytes, application/octet-stream)
2007-10-05 13:11 EDT, Mike M CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mike M CLA 2007-10-05 13:11:00 EDT
Created attachment 79821 [details]
Code to reproduce

Build ID: I20070621-1340

Steps To Reproduce:
1. Create and save the attached source file.
2. Compile it (or notice the red underlining).
3. The following compiler error will appear for the line where "make" is called (line 14):
"Type mismatch: cannot convert from A.Map<Class<capture#1-of ?>,A> to A.Map<Class<?>,A>"
Comment 1 Maxime Daniel CLA 2007-10-05 13:19:54 EDT
Reproduced with Build id: I20070925-1406 *but* javac 6 reports the same.
Comment 2 Olivier Thomann CLA 2007-10-05 13:25:11 EDT
From javac 1.6_03:

A.java:14: incompatible types
found   : A.Map<java.lang.Class<capture#173 of ?>,A>
required: A.Map<java.lang.Class<?>,A>
        return make( type, value );
                   ^
1 error

From JDK1.5.0_13:
A.java:14: incompatible types
found   : A.Map<java.lang.Class<capture of ?>,A>
required: A.Map<java.lang.Class<?>,A>
        return make( type, value );
                   ^
1 error

Eclipse (HEAD):
----------
1. ERROR in D:\tests_sources\A.java (at line 14)
	return make( type, value );
	       ^^^^^^^^^^^^^^^^^^^
Type mismatch: cannot convert from A.Map<Class<capture#1-of ?>,A> to A.Map<Class<?>,A>
----------

it looks consistent over different implementation.
Comment 3 Philipe Mulet CLA 2007-10-12 07:53:46 EDT
Indeed, argument containment rules are stricter. Basically, a wildcard at depth 2 is not as flexible as a wildcard at depth 1.

Class<*anything*> is compatible with Class<?>
but
Class<Class<*anything*>> is not compatible with Class<Class<?>>

Marking as INVALID, since current behavior is fine.
Good testcase btw, added GenericTypeTest#test1200
Comment 4 Maxime Daniel CLA 2007-10-29 05:20:01 EDT
Verified for 3.4 M3 using build I20071029-0010.