diff options
| author | Sasikanth Bharadwaj | 2016-11-18 05:42:37 +0000 |
|---|---|---|
| committer | Sasikanth Bharadwaj | 2016-11-22 08:08:53 +0000 |
| commit | cfc8f74b9c8820b855dd3ffbed748d7233058b28 (patch) | |
| tree | bdbf9edefcd38fad79475a5ae8860ad558c4fe90 | |
| parent | 2f5332d805e4345ca332845bb7370faf6de0b1e1 (diff) | |
| download | eclipse.jdt.core-cfc8f74b9c8820b855dd3ffbed748d7233058b28.tar.gz eclipse.jdt.core-cfc8f74b9c8820b855dd3ffbed748d7233058b28.tar.xz eclipse.jdt.core-cfc8f74b9c8820b855dd3ffbed748d7233058b28.zip | |
Fixed bug 488663 - redundant type arguments analysis for anonymous types
should occur only at source level 9 and above
Change-Id: Id0fc9b9096bc91d1bd957ffcf9b82ee646669d72
2 files changed, 21 insertions, 1 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_8.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_8.java index 5b965903c4..5cfdecbdfb 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_8.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_8.java @@ -7309,4 +7309,23 @@ public void testBug499725() { "}\n" }); } +// Redundant type argument specification error for anonymous types should not occur below source level 9 +public void testBug488663() { + Map<String, String> options = getCompilerOptions(); + options.put(CompilerOptions.OPTION_ReportRedundantSpecificationOfTypeArguments, CompilerOptions.ERROR); + this.runConformTest( + new String[] { + "C.java", + "import java.util.Comparator;\n" + + "public class C {\n" + + " Comparator<String> comparator = new Comparator<String>() { //\n" + + " @Override\n" + + " public int compare(String o1, String o2) {\n" + + " return 0;\n" + + " }\n" + + " };\n" + + "}" + }, + "", options); +} } diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java index e2cdfd35dc..81ef27f4c2 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java @@ -581,7 +581,8 @@ public class QualifiedAllocationExpression extends AllocationExpression { } this.enclosingInstance.computeConversion(scope, targetEnclosing, enclosingInstanceType); } - if (!isDiamond && receiverType.isParameterizedTypeWithActualArguments()) { + if (!isDiamond && receiverType.isParameterizedTypeWithActualArguments() && + (this.anonymousType == null || sourceLevel >= ClassFileConstants.JDK9)) { checkTypeArgumentRedundancy((ParameterizedTypeBinding) receiverType, scope); } if (this.anonymousType != null) { |
