Bug 97494 - [1.5][compiler] Inappropriate error level and message for generic type mismatch
Summary: [1.5][compiler] Inappropriate error level and message for generic type mismatch
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 (vote)
Target Milestone: 3.2 RC1   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-05-31 10:39 EDT by Maxime Daniel CLA
Modified: 2006-04-13 14:11 EDT (History)
1 user (show)

See Also:


Attachments
Batch compiler test case that shows the problem (1.43 KB, patch)
2005-05-31 10:44 EDT, Maxime Daniel CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Maxime Daniel CLA 2005-05-31 10:39:57 EDT
Forked from https://bugs.eclipse.org/bugs/show_bug.cgi?id=93377 (bug 5 there).
Reproduced with 3.1 RC1 (aka build  I20050527-1300).

On the following code:
public class X<T> {
  protected static final Class<X<?>> theClass = (Class<X<?>>) X.class;
}
Eclipse reports a warning:
Severity	Description	Resource	In Folder	Location	Creation Time
Type safety: The cast from Class<X> to Class<X<?>> is actually checking against
the erased type Class
whereas javac reports an error:
X.java:2: inconvertible types
found   : java.lang.Class<X>
required: java.lang.Class<X<?>>
        protected static final Class<X<?>> theClass = (Class<X<?>>) X.class;
                                                                     ^
1 error
Comment 1 Maxime Daniel CLA 2005-05-31 10:44:48 EDT
Created attachment 22045 [details]
Batch compiler test case that shows the problem

Note that _test29 needs to be renamed as test29 to get activated.
Comment 2 Philipe Mulet CLA 2005-05-31 12:59:43 EDT
I believe this is a bug in javac.
Comment 3 Philipe Mulet CLA 2006-04-04 07:40:00 EDT
Actually, I take previous comment back. The types involved are provably distinct, and thus cast should be rejected.

Added GenericTypeTest#test0965.
Fixed
Comment 4 Frederic Fusier CLA 2006-04-13 14:11:56 EDT
Verified for 3.2 RC1 using build I20060413-0010.