JavaNullInterop
This module defines methods to interpret types of Java symbols, which are implicitly nullable in Java, as Scala types, which are explicitly nullable.
The transformation is (conceptually) a function n that adheres to the following rules: (1) n(T) = T | Null if T is a reference type (2) n(T) = T if T is a value type (3) n(C[T]) = C[T] | Null if C is Java-defined (4) n(C[T]) = C[n(T)] | Null if C is Scala-defined (5) n(A|B) = n(A) | n(B) | Null (6) n(A&B) = n(A) & n(B) (7) n((A1, ..., Am)R) = (n(A1), ..., n(Am))n(R) for a method with arguments (A1, ..., Am) and return type R (8) n(T) = T otherwise
Treatment of generics (rules 3 and 4):
- if 
Cis Java-defined, thenn(C[T]) = C[T] | Null. That is, we don't recurse on the type argument, and only add Null on the outside. This is becauseCitself will be nullified, and in particular so will be usages ofC's type argument within C's body. e.g. callinggeton ajava.util.List[String]already returnsString|Nulland notString, so we don't need to writejava.util.List[String | Null]. - if 
Cis Scala-defined, however, then we wantn(C[T]) = C[n(T)] | Null. This is becauseCwon't be nullified, so we need to indicate that its type argument is nullable. 
Notice that since the transformation is only applied to types attached to Java symbols, it doesn't need to handle the full spectrum of Scala types. Additionally, some kinds of symbols like constructors and enum instances get special treatment.
Attributes
- Graph
 - 
    
 - Supertypes
 - Self type
 - 
    JavaNullInterop.type