Summary: | [1.5] Trouble with "unnecassary cast" warnings | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Stefan Matthias Aust <sma> |
Component: | Core | Assignee: | Philipe Mulet <philippe_mulet> |
Status: | RESOLVED FIXED | QA Contact: | |
Severity: | normal | ||
Priority: | P3 | ||
Version: | 3.0 | ||
Target Milestone: | 3.1 M1 | ||
Hardware: | PC | ||
OS: | Windows XP | ||
Whiteboard: |
Description
Stefan Matthias Aust
2004-07-06 08:12:36 EDT
I forgot: I'm using Eclipse 3.0 final and latest jdt.core from HEAD and jdt.ui from JDK_1.5 branch. The unnecessary cast diagnosis definitely looks like a bug. Actually, the diagnosis is fine, as conversion from raw is always legite. We should however issue an unsafe type operation warning. Tuned unsafe type operation warnings. Added regression tests GenericTypeTest#test227,test228. Fixed. This example raises two warnings now - both the unneeded cast and the unsafe case operation. I think, that's too much :) import java.util.List; public class A { List find() { return null; } void m() { for (A a : (List<A>) find()) { System.out.println(a); } } } I don't think it is that bad. Remember that these 2 diagnosises are independant one from each other. They happen to occur at same location, and are 2 reasons for getting rid of this cast. Well, my problem is that both warnings are contradictory. If you let QuickFix "repair" the unneccessary cast warning, this creates an error. OTOH, you have to use the specialisation (and live with the other warning) because otherwise the for loop doesn't work. Therefore, I don't think that the cast is uneccessary. |