@@ -274,22 +274,20 @@ object ScalaRunTime {
274
274
case s => s + " \n "
275
275
}
276
276
277
- // Convert arrays to immutable.ArraySeq for use with Java varargs:
278
- def genericWrapArray [T ](xs : Array [T ]): ArraySeq [T ] =
279
- if (xs eq null ) null
280
- else ArraySeq .unsafeWrapArray(xs)
281
- def wrapRefArray [T <: AnyRef ](xs : Array [T ]): ArraySeq [T ] = {
282
- if (xs eq null ) null
283
- else if (xs.length == 0 ) ArraySeq .empty[AnyRef ].asInstanceOf [ArraySeq [T ]]
284
- else new ArraySeq .ofRef[T ](xs)
285
- }
286
- def wrapIntArray (xs : Array [Int ]): ArraySeq [Int ] = if (xs ne null ) new ArraySeq .ofInt(xs) else null
287
- def wrapDoubleArray (xs : Array [Double ]): ArraySeq [Double ] = if (xs ne null ) new ArraySeq .ofDouble(xs) else null
288
- def wrapLongArray (xs : Array [Long ]): ArraySeq [Long ] = if (xs ne null ) new ArraySeq .ofLong(xs) else null
289
- def wrapFloatArray (xs : Array [Float ]): ArraySeq [Float ] = if (xs ne null ) new ArraySeq .ofFloat(xs) else null
290
- def wrapCharArray (xs : Array [Char ]): ArraySeq [Char ] = if (xs ne null ) new ArraySeq .ofChar(xs) else null
291
- def wrapByteArray (xs : Array [Byte ]): ArraySeq [Byte ] = if (xs ne null ) new ArraySeq .ofByte(xs) else null
292
- def wrapShortArray (xs : Array [Short ]): ArraySeq [Short ] = if (xs ne null ) new ArraySeq .ofShort(xs) else null
293
- def wrapBooleanArray (xs : Array [Boolean ]): ArraySeq [Boolean ] = if (xs ne null ) new ArraySeq .ofBoolean(xs) else null
294
- def wrapUnitArray (xs : Array [Unit ]): ArraySeq [Unit ] = if (xs ne null ) new ArraySeq .ofUnit(xs) else null
277
+ // Convert arrays to immutable.ArraySeq for use with Scala varargs.
278
+ // By construction, calls to these methods always receive a fresh (and non-null), non-empty array.
279
+ // In cases where an empty array would appear, the compiler uses a direct reference to Nil instead.
280
+ // Synthetic Java varargs forwarders (@annotation.varargs or varargs bridges when overriding) may pass
281
+ // `null` to these methods; but returning `null` or `ArraySeq(null)` makes little difference in practice.
282
+ def genericWrapArray [T ](xs : Array [T ]): ArraySeq [T ] = ArraySeq .unsafeWrapArray(xs)
283
+ def wrapRefArray [T <: AnyRef ](xs : Array [T ]): ArraySeq [T ] = new ArraySeq .ofRef[T ](xs)
284
+ def wrapIntArray (xs : Array [Int ]): ArraySeq [Int ] = new ArraySeq .ofInt(xs)
285
+ def wrapDoubleArray (xs : Array [Double ]): ArraySeq [Double ] = new ArraySeq .ofDouble(xs)
286
+ def wrapLongArray (xs : Array [Long ]): ArraySeq [Long ] = new ArraySeq .ofLong(xs)
287
+ def wrapFloatArray (xs : Array [Float ]): ArraySeq [Float ] = new ArraySeq .ofFloat(xs)
288
+ def wrapCharArray (xs : Array [Char ]): ArraySeq [Char ] = new ArraySeq .ofChar(xs)
289
+ def wrapByteArray (xs : Array [Byte ]): ArraySeq [Byte ] = new ArraySeq .ofByte(xs)
290
+ def wrapShortArray (xs : Array [Short ]): ArraySeq [Short ] = new ArraySeq .ofShort(xs)
291
+ def wrapBooleanArray (xs : Array [Boolean ]): ArraySeq [Boolean ] = new ArraySeq .ofBoolean(xs)
292
+ def wrapUnitArray (xs : Array [Unit ]): ArraySeq [Unit ] = new ArraySeq .ofUnit(xs)
295
293
}
0 commit comments