diff options
author | Till Brychcy | 2017-02-04 09:29:14 +0000 |
---|---|---|
committer | Till Brychcy | 2017-02-05 20:59:06 +0000 |
commit | 14ca84b75ceef4e491144249b7445b6bcfc276c6 (patch) | |
tree | e8ecf6127b78d4dda0e3cf968f03f4f7e25a3134 /org.eclipse.jdt.core.tests.compiler | |
parent | 265a71c883de0f578a309877285f7e93b41a8fcf (diff) | |
download | eclipse.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.java | 40 |
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" + ); +} } |