COBCH1872 AS IF can only be used with a reference type or a nullable type

The program contains an AS IF operator that targets a type for which no null value is available. This is not allowed. The AS IF operator can only be used to target types for which a suitable null value is available, meaning reference types or nullable value types.

Resolution:

Correct the code; then recompile.

Example:

The following example shows the correct use of AS and the incorrect use of AS IS.

       class-id A.
       method-id main static.
           declare o1 as object = type System.DateTime::Now
           declare dt1 = o1 as type System.DateTime       *> ok, will unbox o1
           declare dt2 = o1 as if type System.DateTime    *> Error, as there is no null value
           display dt1
       end method.
       end class.