Summary: | [clean up] cleanup changes logic by removing cast that it shouldn't | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Dominik Stadler <dominik.stadler> |
Component: | Core | Assignee: | Philipe Mulet <philippe_mulet> |
Status: | RESOLVED DUPLICATE | QA Contact: | |
Severity: | major | ||
Priority: | P3 | CC: | benno.baumgartner |
Version: | 3.2 | ||
Target Milestone: | 3.3 M3 | ||
Hardware: | PC | ||
OS: | Windows XP | ||
Whiteboard: |
Description
Dominik Stadler
2006-10-06 06:06:31 EDT
Move to JDT/UI Could be related to a wrong diagnosis for unnecessary cast (haven't investigated) This is correct Philippe, the clean up just removes all casts which are reported as unnecessary by the compiler (JavaCore.COMPILER_PB_UNNECESSARY_TYPE_CHECK): I20061003-0800 public class Test { public static void main(String[] s) { Object[] o= new Object[] {(long)1234567}; if (o[0].equals((long)1234567)) { System.out.println("!Bumm"); } else { System.out.println("Bumm"); } } } The first cast is repored as unnecessary, but removing it does change the semantic of the code silently. Raising to major since this semantic change is hard to detect for the user and the 'remove unnecessary casts' clean up is enabled by default. Interestingly, we only issue offending unnecessary cast warning for array initializers. public class X { public static void main(String[] s) { Object o1 = (long) 1234567; // no unnecessary cast warning Object[] os1 = new Object[] { (long) 1234567 }; // should not warn } } More scenarii, only array initializers are complaining. public class X { public static void main(String[] s) { Object o1 = (long) 1234567; Object[] os1 = new Object[] { (long) 1234567 }; Object[] os2 = { (long) 1234567 }; foo((long) 1234567); } static void foo(Object o) { } } Added AutoboxingTest#test128. Problem in fact comes from issue described on bug 162400. Checked that fix for bug 162400 actually addresses this issue as well; since when expected type is properly set for array initializer expressions, the unnecessary cast diagnosis behaves properly from now on. Marking as dup of bug 162400, same problem, just different symptoms. *** This bug has been marked as a duplicate of 162400 *** |