### 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.102 diff -u -r1.102 ASTNode.java --- compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java 6 May 2010 18:37:17 -0000 1.102 +++ compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java 10 May 2010 19:29:53 -0000 @@ -587,29 +587,50 @@ case Binding.FIELD : FieldBinding field = (FieldBinding) recipient; field.tagBits = ((FieldBinding) annotationRecipient).tagBits; + if (annotations != null) { + // need to fill the instances array + for (int j = 0; j < length; j++) { + Annotation annot = sourceAnnotations[j]; + annotations[j] = annot.getCompilerAnnotation(); + } + } break; case Binding.LOCAL : LocalVariableBinding local = (LocalVariableBinding) recipient; 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) { + if ((otherLocalTagBits & TagBits.AnnotationSuppressWarnings) == 0) { + // None of the annotations is a SuppressWarnings annotation + // need to fill the instances array + if (annotations != null) { + for (int j = 0; j < length; j++) { + Annotation annot = sourceAnnotations[j]; + annotations[j] = annot.getCompilerAnnotation(); + } + } + } else if (annotations != null) { + // One of the annotations at least is a SuppressWarnings annotation LocalDeclaration localDeclaration = local.declaration; - annotation.recordSuppressWarnings(scope, localDeclaration.declarationSourceStart, localDeclaration.declarationSourceEnd, scope.compilerOptions().suppressWarnings); + int declarationSourceEnd = localDeclaration.declarationSourceEnd; + int declarationSourceStart = localDeclaration.declarationSourceStart; + for (int j = 0; j < length; j++) { + Annotation annot = sourceAnnotations[j]; + /* + * Annotations are shared between two locals, but we still need to record + * the suppress annotation range for the second local + */ + AnnotationBinding annotationBinding = annot.getCompilerAnnotation(); + annotations[j] = annotationBinding; + if (annotationBinding != null) { + final ReferenceBinding annotationType = annotationBinding.getAnnotationType(); + if (annotationType != null && annotationType.id == TypeIds.T_JavaLangSuppressWarnings) { + annot.recordSuppressWarnings(scope, declarationSourceStart, declarationSourceEnd, scope.compilerOptions().suppressWarnings); + } + } + } } break; } - if (annotations != null) { - // need to fill the instances array - annotations[0] = annotation.getCompilerAnnotation(); - for (int j = 1; j < length; j++) { - Annotation annot = sourceAnnotations[j]; - annotations[j] = annot.getCompilerAnnotation(); - } - } return; } else { annotation.recipient = recipient; #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.215 diff -u -r1.215 AnnotationTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java 6 May 2010 18:37:16 -0000 1.215 +++ src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java 10 May 2010 19:29:59 -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[] { 287, 288 }; +// TESTS_NUMBERS = new int[] { 289 }; // TESTS_RANGE = new int[] { 249, -1 }; } @@ -9518,7 +9518,7 @@ raiseDeprecationReduceInvalidJavadocSeverity, null); } -//https://bugs.eclipse.org/bugs/show_bug.cgi?id=304031 +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=311849 public void test287() { Map options = getCompilerOptions(); options.put(CompilerOptions.OPTION_ReportUncheckedTypeOperation, CompilerOptions.ERROR); @@ -9548,7 +9548,7 @@ options, null); } -//https://bugs.eclipse.org/bugs/show_bug.cgi?id=304031 +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=311849 public void test288() { Map options = getCompilerOptions(); options.put(CompilerOptions.OPTION_ReportUncheckedTypeOperation, CompilerOptions.ERROR); @@ -9572,4 +9572,38 @@ options, null); } +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=311849 +public void test289() { + Map options = getCompilerOptions(); + options.put(CompilerOptions.OPTION_ReportUncheckedTypeOperation, CompilerOptions.ERROR); + options.put(CompilerOptions.OPTION_ReportRawTypeReference, CompilerOptions.IGNORE); + options.put(CompilerOptions.OPTION_SuppressOptionalErrors, CompilerOptions.ENABLED); + this.runConformTest( + new String[] { + "X.java", + "import java.util.ArrayList;\n" + + "\n" + + "public class X {\n" + + " void foo(ArrayList arg) {\n" + + " for (\n" + + " @Deprecated\n" + + " @Other\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" + + "}", + "Other.java", + "@interface Other {}" + }, + "", + null, + true, + null, + options, + null); +} }