diff options
author | Till Brychcy | 2017-03-10 21:26:01 +0000 |
---|---|---|
committer | Till Brychcy | 2017-03-15 07:17:29 +0000 |
commit | 13d670fd72f8d5b353e0a0c08df4eefd9d2de59c (patch) | |
tree | 67069878fd17bc850ee10b5432b7e3261968f0ef /org.eclipse.jdt.core.tests.compiler/src | |
parent | 9470876ed534a44ad527e894428c9392db06ae9d (diff) | |
download | eclipse.jdt.core-13d670fd72f8d5b353e0a0c08df4eefd9d2de59c.tar.gz eclipse.jdt.core-13d670fd72f8d5b353e0a0c08df4eefd9d2de59c.tar.xz eclipse.jdt.core-13d670fd72f8d5b353e0a0c08df4eefd9d2de59c.zip |
Bug 513495 - [null][1.8] Missing warning if method reference mapsI20170317-2000I20170316-2000I20170315-2000
@Nullable first arg to receiver
Change-Id: Ie343dcef76136342173e6016a87e6871ba174a84
Diffstat (limited to 'org.eclipse.jdt.core.tests.compiler/src')
-rw-r--r-- | org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullTypeAnnotationTest.java | 32 |
1 files changed, 32 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 d327440455..4b4bae19b2 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 @@ -15108,4 +15108,36 @@ public void testBug498084b() { "----------\n" ); } +public void testBug513495() { + runNegativeTestWithLibs( + new String[] { + "test/Test3.java", + "package test;\n" + + "\n" + + "import java.util.function.Function;\n" + + "\n" + + "import org.eclipse.jdt.annotation.Nullable;\n" + + "\n" + + "public class Test3 {\n" + + " public static void main(String[] args) {\n" + + " Function<@Nullable Integer, Object> sam = Integer::intValue;\n" + + " sam.apply(null); // <- NullPointerExpection\n" + + " Function<Integer, Object> sam2 = Integer::intValue;\n" + + " sam2.apply(null); // variation: unchecked, so intentionally no warning reported, but would give NPE too \n" + + " }\n" + + " void wildcards(Class<?>[] params) { // unchecked case with wildcards\n" + + " java.util.Arrays.stream(params).map(Class::getName).toArray(String[]::new);\n" + + " }\n" + + "}\n" + + "", + }, + getCompilerOptions(), + "----------\n" + + "1. ERROR in test\\Test3.java (at line 9)\n" + + " Function<@Nullable Integer, Object> sam = Integer::intValue;\n" + + " ^^^^^^^^^^^^^^^^^\n" + + "Null type mismatch at parameter 'this': required \'@NonNull Integer\' but provided \'@Nullable Integer\' via method descriptor Function<Integer,Object>.apply(Integer)\n" + + "----------\n" + ); +} } |