You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We sometimes need to erase `Array[T]` to `Object` instead of
`Array[erasure(T)]` in method signatures, this happens when both
primitive and reference arrays, or two different sort of primitive
arrays could be passed as arguments because the lub of those types on
the JVM is `Object`. But before this commit, we additionally erased
Arrays whose element type is upper-bounded by a universal trait to
Object (like `Array[_ <: Serializable]`), this isn't necessary since
primitives do not extend those traits (except for compiler fictions like
`Singleton`) and derived value classes in arrays are always boxed.
Since having matching Scala 2 and 3 erasure is a lost cause (cf #11603),
this commit align ourselves with Java which improves Java
interop (because we can emit more accurate Java generic signatures) and
should let us simplify erasure more in the future.
It also turns out than even before this commit, we did not match Scala 2
erasure perfectly since we erase `Array[_ <: Int]` to `Array[Int]`
whereas Scala 2 erases to `Object` (this is important since we want
`IArray[Int]` to be erased to `Array[Int]`), so we need to special case
Scala 2 array erasure anyway to handle this.
This commit renames `isUnboundedGeneric` to `isGenericArrayElement`
since the former was somewhat misleading, `T <: String | Any` is
bounded, but `Array[T]` cannot be represented with a specific JVM array
type.
0 commit comments