diff options
author | Olivier Thomann | 2010-05-06 20:56:52 +0000 |
---|---|---|
committer | Olivier Thomann | 2010-05-06 20:56:52 +0000 |
commit | 0932d0fb4e43b1379b1c286eb1af8bd99bf0e6e1 (patch) | |
tree | 3bd2e19f78b1c69a5905f4ae0a76f67a498e4e77 | |
parent | f6c9fb5513237f18cd0d35a560097d90f0d44ed8 (diff) | |
download | eclipse.jdt.core-0932d0fb4e43b1379b1c286eb1af8bd99bf0e6e1.tar.gz eclipse.jdt.core-0932d0fb4e43b1379b1c286eb1af8bd99bf0e6e1.tar.xz eclipse.jdt.core-0932d0fb4e43b1379b1c286eb1af8bd99bf0e6e1.zip |
JSR_308 - Fix for 311849
4 files changed, 74 insertions, 4 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java index e4a5ff5893..6ce3c1fc05 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java @@ -45,7 +45,7 @@ public class AnnotationTest extends AbstractComparableTest { // 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 @@ public void test286() { 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); +} } diff --git a/org.eclipse.jdt.core/buildnotes_jdt-core.html b/org.eclipse.jdt.core/buildnotes_jdt-core.html index 0d008acfbb..7ae10a5827 100644 --- a/org.eclipse.jdt.core/buildnotes_jdt-core.html +++ b/org.eclipse.jdt.core/buildnotes_jdt-core.html @@ -50,7 +50,9 @@ Eclipse SDK 3.6RC1 - %date% - 3.6.0 RC1 <h2>What's new in this drop</h2> <h3>Problem Reports Fixed</h3> -<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=298844">298844</a> +<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=311849">311849</a> +[quick fix] @SuppressWarnings does not work as expected inside a for loop +<br><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=298844">298844</a> [formatter] New lines in empty method body wrong behavior <br><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=311864">311864</a> [formatter] NPE with empty {@code } diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java index 095e87752e..16626ce272 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java @@ -628,7 +628,16 @@ public abstract class ASTNode implements TypeConstants, TypeIds { 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) { diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AbstractVariableDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AbstractVariableDeclaration.java index e3dbaa8829..d69c84f7d7 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AbstractVariableDeclaration.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AbstractVariableDeclaration.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -19,6 +19,11 @@ import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; public abstract class AbstractVariableDeclaration extends Statement implements InvocationSite { public int declarationEnd; + /** + * For local declarations (outside of for statement initialization) and field declarations, + * the declarationSourceEnd covers multiple locals if any. + * For local declarations inside for statement initialization, this is not the case. + */ public int declarationSourceEnd; public int declarationSourceStart; public int hiddenVariableDepth; // used to diagnose hiding scenarii |