Summary: | [1.5][compiler] Usage of raw type: exclude "extends something" | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Marvin Fröhlich <eclipse> |
Component: | Core | Assignee: | Srikanth Sankaran <srikanth_sankaran> |
Status: | VERIFIED INVALID | QA Contact: | |
Severity: | normal | ||
Priority: | P3 | CC: | Olivier_Thomann, satyam.kandula |
Version: | 3.5 | ||
Target Milestone: | 3.6 RC4 | ||
Hardware: | PC | ||
OS: | Linux | ||
Whiteboard: |
Description
Marvin Fröhlich
2010-05-19 08:32:28 EDT
(In reply to comment #0) [...] > If I restrict the generic type parameter to subclasses of something, it is > clear, that if used untypedly, it is treated as it is typed with <Something> > (the base type). These matters are dictated by the language specification and the compiler is not at liberty to treat the raw type C as though it were C<Something>. Per section 5.1.9 Unchecked Conversion of JLS, an expression of type C when converted to C<Something>, must generate an unchecked warning. This is not possible if C were treated to be C<Something> in the first place as you propose in: class C<T extends X> { C c1 = new C(); C<X> c = c1; // MUST generate a warning here. } class X { } The unchecked warnings indicate potentially serious problems. OTOH the raw type usage warning is intended for folks who want to generify their code and need the help of the compiler in locating all places where raw types are used and as such the situations you cite are good candidates for the warnings. Based on project needs, these warnings can be suppressed wholesale or individual basis using annotations. Verified for 3.6RC4 |