Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTill Brychcy2019-08-05 19:11:25 +0000
committerTill Brychcy2019-08-06 07:58:50 +0000
commit09c981c162e7636381343530354a0bacc9b1fc19 (patch)
treeaec862fa0ebe808b380cc918a793811dea2d725b
parentd0c76762c053346997553cc62592c904876efdf6 (diff)
downloadeclipse.jdt.core-09c981c162e7636381343530354a0bacc9b1fc19.tar.gz
eclipse.jdt.core-09c981c162e7636381343530354a0bacc9b1fc19.tar.xz
eclipse.jdt.core-09c981c162e7636381343530354a0bacc9b1fc19.zip
Bug 499714 - [1.8][null] incorrect wording of warning regarding a type
variable constraint to @Nullable - fix regression Change-Id: I9f4dea786d3f8b807ecb53ad736cf4e00f9dfc7a
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullAnnotationTest.java35
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/FlowInfo.java2
2 files changed, 36 insertions, 1 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullAnnotationTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullAnnotationTest.java
index 1ffab25200..56063c837f 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullAnnotationTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullAnnotationTest.java
@@ -10606,4 +10606,39 @@ public void testBug545715() {
customOptions,
new String[] {"--enable-preview"});
}
+public void testBug499714() {
+ runConformTestWithLibs(
+ new String[] {
+ "test/X.java",
+ "package test;\n" +
+ "\n" +
+ "import org.eclipse.jdt.annotation.NonNullByDefault;\n" +
+ "import org.eclipse.jdt.annotation.Nullable;\n" +
+ "\n" +
+ "@NonNullByDefault\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " Object o = null;\n" +
+ " for (final String s : args) {\n" +
+ " if (s.equals(\"-x\")) {\n" +
+ " if (o != null) { // bogus warning here\n" +
+ " //\n" +
+ " }\n" +
+ " continue;\n" +
+ " }\n" +
+ " o = read();\n" +
+ " }\n" +
+ " }\n" +
+ "\n" +
+ " @Nullable\n" +
+ " public static Object read() {\n" +
+ " return \"\";\n" +
+ " }\n" +
+ "}\n" +
+ "",
+ },
+ getCompilerOptions(),
+ ""
+ );
+}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/FlowInfo.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/FlowInfo.java
index 495819a8cb..e45954b760 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/FlowInfo.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/FlowInfo.java
@@ -686,7 +686,7 @@ public static int tagBitsToNullStatus(long tagBits) {
if ((tagBits & TagBits.AnnotationNonNull) != 0)
return NON_NULL;
if ((tagBits & TagBits.AnnotationNullable) != 0)
- return POTENTIALLY_NULL;
+ return POTENTIALLY_NULL | FlowInfo.POTENTIALLY_UNKNOWN;
return UNKNOWN;
}
}

Back to the top