changeset 3268:572d8ea3ca59

Fix: add tests
author mcimadamore
date Fri, 04 Dec 2015 19:24:44 +0000
parents 2568113d414c
children 6a8a8a94eaef
files test/tools/javac/valhalla/values/CheckNullCastable.java test/tools/javac/valhalla/values/CheckNullCastable.out
diffstat 2 files changed, 18 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/valhalla/values/CheckNullCastable.java	Fri Dec 04 19:24:44 2015 +0000
@@ -0,0 +1,14 @@
+/*
+ * @test /nodynamiccopyright/
+ * @summary null cannot be casted to and compared with value types.
+ *
+ * @compile/fail/ref=CheckNullCastable.out -XDrawDiagnostics CheckNullCastable.java
+ */
+
+__ByValue final class CheckNullCastable {
+    void foo(CheckNullCastable cnc) {
+        CheckNullCastable cncl = (CheckNullCastable) null;
+        if (cnc != null) {};
+        if (null != cnc) {};
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/valhalla/values/CheckNullCastable.out	Fri Dec 04 19:24:44 2015 +0000
@@ -0,0 +1,4 @@
+CheckNullCastable.java:10:54: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.type.null, CheckNullCastable)
+CheckNullCastable.java:11:17: compiler.err.incomparable.types: CheckNullCastable, compiler.misc.type.null
+CheckNullCastable.java:12:18: compiler.err.incomparable.types: compiler.misc.type.null, CheckNullCastable
+3 errors