@@ -54,7 +54,7 @@ object ScalaRunTime {
5454 classTag[T ].runtimeClass.asInstanceOf [jClass[T ]]
5555
5656 /** Retrieve generic array element */
57- def array_apply (xs : AnyRef | Null , idx : Int ): Any = {
57+ def array_apply (xs : AnyRef , idx : Int ): Any = {
5858 (xs : @ unchecked) match {
5959 case x : Array [AnyRef ] => x(idx).asInstanceOf [Any ]
6060 case x : Array [Int ] => x(idx).asInstanceOf [Any ]
@@ -70,7 +70,7 @@ object ScalaRunTime {
7070 }
7171
7272 /** update generic array element */
73- def array_update (xs : AnyRef | Null , idx : Int , value : Any ): Unit = {
73+ def array_update (xs : AnyRef , idx : Int , value : Any ): Unit = {
7474 (xs : @ unchecked) match {
7575 case x : Array [AnyRef ] => x(idx) = value.asInstanceOf [AnyRef ]
7676 case x : Array [Int ] => x(idx) = value.asInstanceOf [Int ]
@@ -86,11 +86,11 @@ object ScalaRunTime {
8686 }
8787
8888 /** Get generic array length */
89- @ inline def array_length (xs : AnyRef | Null ): Int = java.lang.reflect.Array .getLength(xs)
89+ @ inline def array_length (xs : AnyRef ): Int = java.lang.reflect.Array .getLength(xs)
9090
9191 // TODO: bytecode Object.clone() will in fact work here and avoids
9292 // the type switch. See Array_clone comment in BCodeBodyBuilder.
93- def array_clone (xs : AnyRef | Null ): AnyRef = (xs : @ unchecked) match {
93+ def array_clone (xs : AnyRef ): AnyRef = (xs : @ unchecked) match {
9494 case x : Array [AnyRef ] => x.clone()
9595 case x : Array [Int ] => x.clone()
9696 case x : Array [Double ] => x.clone()
@@ -107,7 +107,7 @@ object ScalaRunTime {
107107 * Needed to deal with vararg arguments of primitive types that are passed
108108 * to a generic Java vararg parameter T ...
109109 */
110- def toObjectArray (src : AnyRef | Null ): Array [Object ] = {
110+ def toObjectArray (src : AnyRef ): Array [Object ] = {
111111 def copy [@ specialized T <: AnyVal ](src : Array [T ]): Array [Object ] = {
112112 val length = src.length
113113 if (length == 0 ) Array .emptyObjectArray
@@ -281,6 +281,14 @@ object ScalaRunTime {
281281 case s => s + " \n "
282282 }
283283
284+ // For backward compatibility with code compiled without -Yexplicit-nulls.
285+ // If `a` is null, return null; otherwise, return `f`.
286+ private [scala] inline def mapNull [A , B ](a : A , inline f : B ): B =
287+ if ((a : A | Null ) == null ) null .asInstanceOf [B ] else f
288+
289+ // Use `null` in places where we want to make sure the reference is cleared.
290+ private [scala] inline def nullForGC [T ]: T = null .asInstanceOf [T ]
291+
284292 // Convert arrays to immutable.ArraySeq for use with Scala varargs.
285293 // By construction, calls to these methods always receive a fresh (and non-null), non-empty array.
286294 // In cases where an empty array would appear, the compiler uses a direct reference to Nil instead.
0 commit comments