Community
Participate
Working Groups
Build Identifier: I20100513-1500 This is FUP of bug 311849. In the following code import java.util.*; class Bug { @SuppressWarnings("rawtypes") void foo(ArrayList arg) { @SuppressWarnings("unchecked") // bad: unnecessary suppressWarnings warn boolean aa = arg.add(1), // good: local variable aa never read warning bb = arg.add(1); if (bb) System.out.println("hi"); } } If either aa or bb is not read the suppressWarnings annotation is warned by the compiler as unnecessary. This is a bogus warning since the annotation applies for atleast one variable in the declaration series. Reproducible: Always Steps to Reproduce: 1.Use the above code 2.See the bogus compiler warning
This was OK in 3.6M7.
This comes from the fact that the annotation is shared for the two locals. I can take a look to see how we can try to fix it.
Targeting 3.6RC2. Will be reassessed once the fix is ready.
The problem comes from the fact that in this case we end up duplicating some information inside the suppress warnings data, because outside of the case for the for statement's initializers, the local declaration source end and local declaration source start are identical for both locals. So we can either fix it by making sure we don't add duplicated information inside the compilation unit suppress warnings data or we modify the grammar to initialize the declaration source end of the local inside for statement's initializers. I have a fix using the first approach. The second way to fix it would also need to revert the patch for bug 311849.
Created attachment 168779 [details] Proposed fix + regression tests
Frédéric, Srikanth, please review.
Patch looks good to me.
(In reply to comment #6) > Frédéric, Srikanth, please review. Patch looks good to me. One cosmetic remark, IMO the isAllSet method name looks a little bit ambiguous as it looks more like an equality between two IrritantSet... Maybe hasSameBits or something similar would be a little bit better?
(In reply to comment #8) > One cosmetic remark, IMO the isAllSet method name looks a little bit ambiguous > as it looks more like an equality between two IrritantSet... Maybe hasSameBits > or something similar would be a little bit better? ok, I'll rename it. Please add the +1
Created attachment 168965 [details] Proposed fix + regression tests Same patch with renamed method. Frédéric, please review.
(In reply to comment #10) > Created an attachment (id=168965) [details] > Proposed fix + regression tests > > Same patch with renamed method. > Frédéric, please review. OK for me: +1
Released for 3.6RC2. Regression tests added in: org.eclipse.jdt.core.tests.compiler.regression.AnnotationTest#test290 org.eclipse.jdt.core.tests.compiler.regression.AnnotationTest#test291 org.eclipse.jdt.core.tests.compiler.regression.AnnotationTest#test292
Verified for 3.6RC2 using build I20100520-1744.