Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTill Brychcy2017-02-04 09:29:14 +0000
committerTill Brychcy2017-02-05 20:59:06 +0000
commit14ca84b75ceef4e491144249b7445b6bcfc276c6 (patch)
treee8ecf6127b78d4dda0e3cf968f03f4f7e25a3134 /org.eclipse.jdt.core.tests.compiler
parent265a71c883de0f578a309877285f7e93b41a8fcf (diff)
downloadeclipse.jdt.core-14ca84b75ceef4e491144249b7445b6bcfc276c6.tar.gz
eclipse.jdt.core-14ca84b75ceef4e491144249b7445b6bcfc276c6.tar.xz
eclipse.jdt.core-14ca84b75ceef4e491144249b7445b6bcfc276c6.zip
Bug 511723 - [1.8][null] improve error message for array access when
pessimistic analysis for free type variables is enabled Change-Id: Iccff6ce59f922300347fb5a7313fbaf3111e0ba7
Diffstat (limited to 'org.eclipse.jdt.core.tests.compiler')
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullTypeAnnotationTest.java40
1 files changed, 40 insertions, 0 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 554081159b..64e800d889 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
@@ -14225,4 +14225,44 @@ public void testBug490403typeArgAnnotationMismatch() {
"----------\n"
);
}
+public void testBug511723() {
+ runNegativeTestWithLibs(
+ new String[] {
+ "test/ArrayVsList.java",
+ "package test;\n" +
+ "\n" +
+ "import org.eclipse.jdt.annotation.NonNull;\n" +
+ "\n" +
+ "public class ArrayVsList {\n" +
+ " static interface List<T> {\n" +
+ " T get(int i);\n" +
+ " }\n" +
+ " public static <T> void f(List<T> list) {\n" +
+ " @NonNull\n" +
+ " Object o = list.get(0); // problem\n" +
+ " o.hashCode();\n" +
+ " }\n" +
+ "\n" +
+ " public static <T> void g(T[] array) {\n" +
+ " @NonNull\n" +
+ " Object o = array[0]; // problem\n" +
+ " o.hashCode();\n" +
+ " }\n" +
+ "}\n" +
+ "",
+ },
+ getCompilerOptions(),
+ "----------\n" +
+ "1. ERROR in test\\ArrayVsList.java (at line 11)\n" +
+ " Object o = list.get(0); // problem\n" +
+ " ^^^^^^^^^^^\n" +
+ "Null type safety: required \'@NonNull\' but this expression has type \'T\', a free type variable that may represent a \'@Nullable\' type\n" +
+ "----------\n" +
+ "2. ERROR in test\\ArrayVsList.java (at line 17)\n" +
+ " Object o = array[0]; // problem\n" +
+ " ^^^^^^^^\n" +
+ "Null type safety: required \'@NonNull\' but this expression has type \'T\', a free type variable that may represent a \'@Nullable\' type\n" +
+ "----------\n"
+ );
+}
}

Back to the top