Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Herrmann2020-02-18 15:01:27 +0000
committerStephan Herrmann2020-02-18 15:01:27 +0000
commit4ce8fc36a787f1398903447a1816ff5fb4392149 (patch)
tree253bc76d56577afb59d2adc53a950c9c89e50c72
parent1a930ae92c069b627b521736fa49ab1dc3794efb (diff)
downloadeclipse.jdt.core-4ce8fc36a787f1398903447a1816ff5fb4392149.tar.gz
eclipse.jdt.core-4ce8fc36a787f1398903447a1816ff5fb4392149.tar.xz
eclipse.jdt.core-4ce8fc36a787f1398903447a1816ff5fb4392149.zip
accessed as BTB - avoid the new problem in this situation for now Change-Id: I32f46cf43d3e06336bcddcf79a9a8a46af384706
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullTypeAnnotationTest.java67
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeVariableBinding.java5
2 files changed, 70 insertions, 2 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullTypeAnnotationTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullTypeAnnotationTest.java
index 66d6ea278a..a89da8868d 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullTypeAnnotationTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullTypeAnnotationTest.java
@@ -17995,4 +17995,71 @@ public void testBug482242_boundedWildcard() {
"Null type safety (type annotations): The expression of type \'String\' needs unchecked conversion to conform to \'capture#of ? super @Nullable String\'\n" +
"----------\n");
}
+public void testBug560213source() {
+ Runner runner = new Runner();
+ runner.customOptions = getCompilerOptions();
+ runner.classLibraries = this.LIBS;
+ runner.testFiles = new String[] {
+ "nullEnumSort/MyEnum.java",
+ "package nullEnumSort;\n" +
+ "\n" +
+ "import org.eclipse.jdt.annotation.NonNullByDefault;\n" +
+ "\n" +
+ "@NonNullByDefault\n" +
+ "enum MyEnum {\n" +
+ " x\n" +
+ "}\n",
+ "nullEnumSort/EnumProblem.java",
+ "package nullEnumSort;\n" +
+ "\n" +
+ "import java.util.Collections;\n" +
+ "import java.util.List;\n" +
+ "\n" +
+ "import org.eclipse.jdt.annotation.NonNullByDefault;\n" +
+ "\n" +
+ "@NonNullByDefault\n" +
+ "public class EnumProblem {\n" +
+ " void f(List<MyEnum> list) {\n" +
+ " Collections.sort(list);\n" +
+ " }\n" +
+ "\n}"
+ };
+ runner.runConformTest();
+}
+public void testBug560213binary() {
+ Runner runner = new Runner();
+ runner.customOptions = getCompilerOptions();
+ runner.testFiles = new String[] {
+ "nullEnumSort/MyEnum.java",
+ "package nullEnumSort;\n" +
+ "\n" +
+ "import org.eclipse.jdt.annotation.NonNullByDefault;\n" +
+ "\n" +
+ "@NonNullByDefault\n" +
+ "enum MyEnum {\n" +
+ " x\n" +
+ "}\n"
+ };
+ runner.classLibraries = this.LIBS;
+ runner.runConformTest();
+
+ runner.shouldFlushOutputDirectory = false;
+ runner.testFiles = new String[] {
+ "nullEnumSort/EnumProblem.java",
+ "package nullEnumSort;\n" +
+ "\n" +
+ "import java.util.Collections;\n" +
+ "import java.util.List;\n" +
+ "\n" +
+ "import org.eclipse.jdt.annotation.NonNullByDefault;\n" +
+ "\n" +
+ "@NonNullByDefault\n" +
+ "public class EnumProblem {\n" +
+ " void f(List<MyEnum> list) {\n" +
+ " Collections.sort(list);\n" +
+ " }\n" +
+ "\n}"
+ };
+ runner.runConformTest();
+}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeVariableBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeVariableBinding.java
index bb3ca2a0b7..9a3eadafc8 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeVariableBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeVariableBinding.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2019 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -295,7 +295,8 @@ public class TypeVariableBinding extends ReferenceBinding {
}
private BoundCheckStatus nullBoundCheck(Scope scope, TypeBinding argumentType, TypeBinding substitutedSuperType, Substitution substitution, ASTNode location, BoundCheckStatus previousStatus) {
- if (NullAnnotationMatching.analyse(this, argumentType, substitutedSuperType, substitution, -1, null, CheckMode.BOUND_CHECK).isAnyMismatch()) {
+ NullAnnotationMatching status = NullAnnotationMatching.analyse(this, argumentType, substitutedSuperType, substitution, -1, null, CheckMode.BOUND_CHECK);
+ if (status.isAnyMismatch() && !status.isAnnotatedToUnannotated()) {
if (location != null)
scope.problemReporter().nullityMismatchTypeArgument(this, argumentType, location);
return BoundCheckStatus.NULL_PROBLEM;

Back to the top