@@ -122,7 +122,7 @@ object Predef extends LowPriorityImplicits {
122
122
* @return The runtime [[Class ]] representation of type `T`.
123
123
* @group utilities
124
124
*/
125
- def classOf [T ]: Class [T ] = null // This is a stub method. The actual implementation is filled in by the compiler.
125
+ def classOf [T ]: Class [T ] = null . asInstanceOf [ Class [ T ]] // This is a stub method. The actual implementation is filled in by the compiler.
126
126
127
127
/**
128
128
* Retrieve the single value of a type with a unique inhabitant.
@@ -286,12 +286,12 @@ object Predef extends LowPriorityImplicits {
286
286
to be available at runtime.
287
287
To achieve this, we keep the Scala 3 signature publicly available.
288
288
We rely on the fact that it is `inline` and will not be visible in the bytecode.
289
- To add the required Scala 2 ones, we define the `scala2Assert`, we use:
290
- - `@targetName` to swap the name in the generated code to `assert`
289
+ To add the required Scala 2 ones, we define the `scala2Assert`, we use:
290
+ - `@targetName` to swap the name in the generated code to `assert`
291
291
- `@publicInBinary` to make it available during runtime.
292
292
As such, we would successfully hijack the definitions of `assert` such as:
293
293
- At compile time, we would have the definitions of `assert`
294
- - At runtime, the definitions of `scala2Assert` as `assert`
294
+ - At runtime, the definitions of `scala2Assert` as `assert`
295
295
NOTE: Tasty-Reader in Scala 2 will have to learn about this swapping if we are to
296
296
allow loading the full Scala 3 library by it.
297
297
*/
@@ -426,7 +426,7 @@ object Predef extends LowPriorityImplicits {
426
426
@ inline def formatted (fmtstr : String ): String = fmtstr format self
427
427
}
428
428
429
- /** Injects String concatenation operator `+` to any classes.
429
+ /** Injects String concatenation operator `+` to any classes.
430
430
* @group implicit-classes-any
431
431
*/
432
432
@ (deprecated @ companionMethod)(" Implicit injection of + is deprecated. Convert to String to call +" , " 2.13.0" )
@@ -658,46 +658,46 @@ private[scala] abstract class LowPriorityImplicits extends LowPriorityImplicits2
658
658
@ inline implicit def booleanWrapper (x : Boolean ): runtime.RichBoolean = new runtime.RichBoolean (x)
659
659
660
660
/** @group conversions-array-to-wrapped-array */
661
- implicit def genericWrapArray [T ](xs : Array [T ]): ArraySeq [T ] =
661
+ implicit def genericWrapArray [T ](xs : Array [T ] | Null ): ArraySeq [T ] | Null =
662
662
if (xs eq null ) null
663
663
else ArraySeq .make(xs)
664
664
665
665
// Since the JVM thinks arrays are covariant, one 0-length Array[AnyRef]
666
666
// is as good as another for all T <: AnyRef. Instead of creating 100,000,000
667
667
// unique ones by way of this implicit, let's share one.
668
668
/** @group conversions-array-to-wrapped-array */
669
- implicit def wrapRefArray [T <: AnyRef ](xs : Array [T ]): ArraySeq .ofRef[T ] = {
669
+ implicit def wrapRefArray [T <: AnyRef ](xs : Array [T ] | Null ): ArraySeq .ofRef[T ] | Null = {
670
670
if (xs eq null ) null
671
671
else if (xs.length == 0 ) ArraySeq .empty[AnyRef ].asInstanceOf [ArraySeq .ofRef[T ]]
672
672
else new ArraySeq .ofRef[T ](xs)
673
673
}
674
674
675
675
/** @group conversions-array-to-wrapped-array */
676
- implicit def wrapIntArray (xs : Array [Int ]): ArraySeq .ofInt = if (xs ne null ) new ArraySeq .ofInt(xs) else null
676
+ implicit def wrapIntArray (xs : Array [Int ] | Null ): ArraySeq .ofInt | Null = if (xs ne null ) new ArraySeq .ofInt(xs) else null
677
677
/** @group conversions-array-to-wrapped-array */
678
- implicit def wrapDoubleArray (xs : Array [Double ]): ArraySeq .ofDouble = if (xs ne null ) new ArraySeq .ofDouble(xs) else null
678
+ implicit def wrapDoubleArray (xs : Array [Double ] | Null ): ArraySeq .ofDouble | Null = if (xs ne null ) new ArraySeq .ofDouble(xs) else null
679
679
/** @group conversions-array-to-wrapped-array */
680
- implicit def wrapLongArray (xs : Array [Long ]): ArraySeq .ofLong = if (xs ne null ) new ArraySeq .ofLong(xs) else null
680
+ implicit def wrapLongArray (xs : Array [Long ] | Null ): ArraySeq .ofLong | Null = if (xs ne null ) new ArraySeq .ofLong(xs) else null
681
681
/** @group conversions-array-to-wrapped-array */
682
- implicit def wrapFloatArray (xs : Array [Float ]): ArraySeq .ofFloat = if (xs ne null ) new ArraySeq .ofFloat(xs) else null
682
+ implicit def wrapFloatArray (xs : Array [Float ] | Null ): ArraySeq .ofFloat | Null = if (xs ne null ) new ArraySeq .ofFloat(xs) else null
683
683
/** @group conversions-array-to-wrapped-array */
684
- implicit def wrapCharArray (xs : Array [Char ]): ArraySeq .ofChar = if (xs ne null ) new ArraySeq .ofChar(xs) else null
684
+ implicit def wrapCharArray (xs : Array [Char ] | Null ): ArraySeq .ofChar | Null = if (xs ne null ) new ArraySeq .ofChar(xs) else null
685
685
/** @group conversions-array-to-wrapped-array */
686
- implicit def wrapByteArray (xs : Array [Byte ]): ArraySeq .ofByte = if (xs ne null ) new ArraySeq .ofByte(xs) else null
686
+ implicit def wrapByteArray (xs : Array [Byte ] | Null ): ArraySeq .ofByte | Null = if (xs ne null ) new ArraySeq .ofByte(xs) else null
687
687
/** @group conversions-array-to-wrapped-array */
688
- implicit def wrapShortArray (xs : Array [Short ]): ArraySeq .ofShort = if (xs ne null ) new ArraySeq .ofShort(xs) else null
688
+ implicit def wrapShortArray (xs : Array [Short ] | Null ): ArraySeq .ofShort | Null = if (xs ne null ) new ArraySeq .ofShort(xs) else null
689
689
/** @group conversions-array-to-wrapped-array */
690
- implicit def wrapBooleanArray (xs : Array [Boolean ]): ArraySeq .ofBoolean = if (xs ne null ) new ArraySeq .ofBoolean(xs) else null
690
+ implicit def wrapBooleanArray (xs : Array [Boolean ] | Null ): ArraySeq .ofBoolean | Null = if (xs ne null ) new ArraySeq .ofBoolean(xs) else null
691
691
/** @group conversions-array-to-wrapped-array */
692
- implicit def wrapUnitArray (xs : Array [Unit ]): ArraySeq .ofUnit = if (xs ne null ) new ArraySeq .ofUnit(xs) else null
692
+ implicit def wrapUnitArray (xs : Array [Unit ] | Null ): ArraySeq .ofUnit | Null = if (xs ne null ) new ArraySeq .ofUnit(xs) else null
693
693
694
694
/** @group conversions-string */
695
- implicit def wrapString (s : String ): WrappedString = if (s ne null ) new WrappedString (s) else null
695
+ implicit def wrapString (s : String | Null ): WrappedString | Null = if (s ne null ) new WrappedString (s) else null
696
696
}
697
697
698
698
private [scala] abstract class LowPriorityImplicits2 {
699
699
@ deprecated(" implicit conversions from Array to immutable.IndexedSeq are implemented by copying; use `toIndexedSeq` explicitly if you want to copy, or use the more efficient non-copying ArraySeq.unsafeWrapArray" , since= " 2.13.0" )
700
- implicit def copyArrayToImmutableIndexedSeq [T ](xs : Array [T ]): IndexedSeq [T ] =
700
+ implicit def copyArrayToImmutableIndexedSeq [T ](xs : Array [T ] | Null ): IndexedSeq [T ] | Null =
701
701
if (xs eq null ) null
702
702
else new ArrayOps (xs).toIndexedSeq
703
703
}
0 commit comments