diff options
author | Manoj Palat | 2013-01-18 06:02:15 +0000 |
---|---|---|
committer | Jayaprakash Arthanareeswaran | 2013-02-05 19:19:25 +0000 |
commit | 4903bbfae682287d2c537deeff6a6697c3022fbb (patch) | |
tree | e1c2e3bdf34a094de449a392a12041810cd5ff4f | |
parent | 42b502cfe7b86a61a34884629d46e24cfbdfaa43 (diff) | |
download | eclipse.jdt.core-4903bbfae682287d2c537deeff6a6697c3022fbb.tar.gz eclipse.jdt.core-4903bbfae682287d2c537deeff6a6697c3022fbb.tar.xz eclipse.jdt.core-4903bbfae682287d2c537deeff6a6697c3022fbb.zip |
Fixed 397888.
3 files changed, 76 insertions, 3 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest.java index 18f29ba7f2..8721046913 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2012 IBM Corporation and others. + * Copyright (c) 2000, 2013 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 @@ -2750,4 +2750,71 @@ public void testBug395002_combined() { }); } +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=397888 +public void test397888a() { + Map customOptions = getCompilerOptions(); + customOptions.put(JavaCore.COMPILER_DOC_COMMENT_SUPPORT, JavaCore.ENABLED); + customOptions.put(CompilerOptions.OPTION_ReportUnusedTypeParameter, CompilerOptions.ERROR); + customOptions.put(CompilerOptions.OPTION_ReportUnusedParameter, CompilerOptions.ERROR); + customOptions.put(CompilerOptions.OPTION_ReportUnusedParameterIncludeDocCommentReference, + CompilerOptions.ENABLED); + + this.runNegativeTest( + new String[] { + "X.java", + "/***\n" + + " * @param <T>\n" + + " */\n" + + "public class X <T> {\n"+ + "/***\n" + + " * @param <S>\n" + + " */\n" + + " public <S> void ph(int i) {\n"+ + " }\n"+ + "}\n" + }, + "----------\n" + + "1. ERROR in X.java (at line 8)\n" + + " public <S> void ph(int i) {\n" + + " ^\n" + + "The value of the parameter i is not used\n" + + "----------\n", + null, true, customOptions); +} + +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=397888 +public void test397888b() { + Map customOptions = getCompilerOptions(); + customOptions.put(JavaCore.COMPILER_DOC_COMMENT_SUPPORT, JavaCore.ENABLED); + customOptions.put(CompilerOptions.OPTION_ReportUnusedTypeParameter, CompilerOptions.ERROR); + customOptions.put(CompilerOptions.OPTION_ReportUnusedParameterIncludeDocCommentReference, + CompilerOptions.DISABLED); + + this.runNegativeTest( + new String[] { + "X.java", + "/***\n" + + " * @param <T>\n" + + " */\n" + + "public class X <T> {\n"+ + "/***\n" + + " * @param <S>\n" + + " */\n" + + "public <S> void ph() {\n"+ + "}\n"+ + "}\n" + }, + "----------\n" + + "1. ERROR in X.java (at line 4)\n" + + " public class X <T> {\n" + + " ^\n" + + "Unused type parameter T\n" + + "----------\n" + + "2. ERROR in X.java (at line 8)\n" + + " public <S> void ph() {\n" + + " ^\n" + + "Unused type parameter S\n" + + "----------\n", + null, true, customOptions); +} }
\ No newline at end of file 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 c8d0a3a503..635d63acae 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 @@ -504,8 +504,9 @@ public abstract class ASTNode implements TypeConstants, TypeIds { return false; ReferenceBinding refType = (ReferenceBinding) type; + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=397888 // https://bugs.eclipse.org/bugs/show_bug.cgi?id=385780 - if (refType instanceof TypeVariableBinding) { + if ((this.bits & ASTNode.InsideJavadoc) == 0 && refType instanceof TypeVariableBinding) { refType.modifiers |= ExtraCompilerModifiers.AccLocallyUsed; } // ignore references insing Javadoc comments diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Javadoc.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Javadoc.java index ba88a60a0d..9e05d89ab9 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Javadoc.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Javadoc.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2011 IBM Corporation and others. + * Copyright (c) 2000, 2013 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 @@ -604,6 +604,11 @@ public class Javadoc extends ASTNode { TypeBinding paramBindind = param.internalResolveType(scope); if (paramBindind != null && paramBindind.isValidBinding()) { if (paramBindind.isTypeVariable()) { + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=397888 + if (scope.compilerOptions().reportUnusedParameterIncludeDocCommentReference) { + TypeVariableBinding typeVariableBinding = (TypeVariableBinding) paramBindind; + typeVariableBinding.modifiers |= ExtraCompilerModifiers.AccLocallyUsed; + } // Verify duplicated tags boolean duplicate = false; for (int j = 0; j < i && !duplicate; j++) { |