Community
Participate
Working Groups
HEAD with fixes for bug 295551 and bug 303945 package xy; public class TestUnused { void m() { @SuppressWarnings("cast") int i= (int) 0; @SuppressWarnings("cast") byte b= (byte) i; System.out.println(b); } } - set "Errors/Warnings > Unnecessary Code > Unnecessary cast or..." to Warning => second '@SuppressWarnings("cast")' has a warning: 'Unnecessary @SuppressWarnings("cast")'. That's good. - check "Errors/Warnings > Annotations > "Suppress optional errors with '@SuppressWarnings'" => warning stays (good) - set "Errors/Warnings > Unnecessary Code > Unnecessary cast or..." to Error => warning on second annotation goes away (should stay)
Created attachment 160333 [details] Proposed fix + regression tests Running all tests to make sure we don't have regressions. We had a check to tolerate unnecessary @SuppressWarnings when errors. This should only apply to mandatory errors.
Created attachment 160334 [details] Proposed fix + regression tests One more regression test.
This means that @SuppressWarnings are reported as unused if the corresponding setting is set to error and the new option is not set. So that code: public class TestUnused { void m() { @SuppressWarnings("cast") int i= (int) 0; @SuppressWarnings("cast") byte b= (byte) i; System.out.println(b); } } with: - set "Errors/Warnings > Unnecessary Code > Unnecessary cast or..." to Error - uncheck "Errors/Warnings > Annotations > "Suppress optional errors with '@SuppressWarnings'" both @SuppressWarnings are reported as unused. Is this what you expect ?
(In reply to comment #3) Yes, that would be fine with me.
Created attachment 160347 [details] Proposed fix + regression tests Updated existing tests.
Released for 3.6M6. Regression tests added in: org.eclipse.jdt.core.tests.compiler.regression.AnnotationTest#test284 org.eclipse.jdt.core.tests.compiler.regression.AnnotationTest#test285 org.eclipse.jdt.core.tests.compiler.regression.AnnotationTest#test286
Verified for 3.6M6 using build I20100307-2000.