1 /*
   2  * @test /nodynamiccopyright/
   3  * @summary Assignment of null to value types should be disallowed.
   4  * @modules java.base/jvm.internal.value
   5  * @compile/fail/ref=CheckNullAssign.out -XDrawDiagnostics -Werror -Xlint:values CheckNullAssign.java
   6  */
   7 @jvm.internal.value.DeriveValueType
   8 final class CheckNullAssign {
   9     CheckNullAssign foo(CheckNullAssign cna) {
  10         // All of the below involve subtype/assignability checks and should be rejected.
  11         CheckNullAssign cnal = null;
  12         cna = null;
  13         foo(null);
  14         if (null instanceof CheckNullAssign) {}
  15         return null;
  16     }
  17 }