### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java,v retrieving revision 1.101 diff -u -r1.101 ASTNode.java --- compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java 11 Feb 2010 01:32:26 -0000 1.101 +++ compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java 6 May 2010 14:23:27 -0000 @@ -590,7 +590,16 @@ break; case Binding.LOCAL : LocalVariableBinding local = (LocalVariableBinding) recipient; - local.tagBits = ((LocalVariableBinding) annotationRecipient).tagBits; + long otherLocalTagBits = ((LocalVariableBinding) annotationRecipient).tagBits; + local.tagBits = otherLocalTagBits; + /* + * Annotations are shared between two locals, but we still need to record + * the suppress annotation range for the second local + */ + if ((otherLocalTagBits & TagBits.AnnotationSuppressWarnings) != 0) { + LocalDeclaration localDeclaration = local.declaration; + annotation.recordSuppressWarnings(scope, localDeclaration.declarationSourceStart, localDeclaration.declarationSourceEnd, scope.compilerOptions().suppressWarnings); + } break; } if (annotations != null) { #P org.eclipse.jdt.core.tests.compiler Index: src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java,v retrieving revision 1.214 diff -u -r1.214 AnnotationTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java 18 Mar 2010 16:22:36 -0000 1.214 +++ src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java 6 May 2010 14:23:30 -0000 @@ -45,7 +45,7 @@ // All specified tests which do not belong to the class are skipped... static { // TESTS_NAMES = new String[] { "test127" }; -// TESTS_NUMBERS = new int[] { 286 }; +// TESTS_NUMBERS = new int[] { 287, 288 }; // TESTS_RANGE = new int[] { 249, -1 }; } @@ -9518,4 +9518,58 @@ raiseDeprecationReduceInvalidJavadocSeverity, null); } +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=304031 +public void test287() { + Map options = getCompilerOptions(); + options.put(CompilerOptions.OPTION_ReportUncheckedTypeOperation, CompilerOptions.ERROR); + options.put(CompilerOptions.OPTION_SuppressOptionalErrors, CompilerOptions.ENABLED); + this.runConformTest( + new String[] { + "X.java", + "import java.util.ArrayList;\n" + + "\n" + + "public class X {\n" + + " @SuppressWarnings(\"rawtypes\")\n" + + " void foo(ArrayList arg) {\n" + + " for (\n" + + " @SuppressWarnings(\"unchecked\")\n" + + " boolean a= arg.add(1), b= arg.add(1);\n" + + " Boolean.FALSE;\n" + + " ) {\n" + + " System.out.println(a && b);\n" + + " }\n" + + " }\n" + + "}", + }, + "", + null, + true, + null, + options, + null); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=304031 +public void test288() { + Map options = getCompilerOptions(); + options.put(CompilerOptions.OPTION_ReportUncheckedTypeOperation, CompilerOptions.ERROR); + options.put(CompilerOptions.OPTION_SuppressOptionalErrors, CompilerOptions.ENABLED); + this.runConformTest( + new String[] { + "X.java", + "import java.util.ArrayList;\n" + + "\n" + + "public class X {\n" + + " @SuppressWarnings(\"rawtypes\")\n" + + " ArrayList arg;\n" + + " @SuppressWarnings(\"unchecked\")\n" + + " boolean a= arg.add(1), b= arg.add(1);\n" + + "}", + }, + "", + null, + true, + null, + options, + null); +} }