@@ -326,7 +326,7 @@ object TypeErasure {
326
326
val sym = t.symbol
327
327
// Only a few classes have both primitives and references as subclasses.
328
328
if (sym eq defn.AnyClass ) || (sym eq defn.AnyValClass ) || (sym eq defn.MatchableClass ) || (sym eq defn.SingletonClass )
329
- || isScala2 && ! (t.derivesFrom(defn.ObjectClass ) || t.isNullType) then
329
+ || isScala2 && ! (t.derivesFrom(defn.ObjectClass ) || t.isNullType | t.isNothingType ) then
330
330
NoSymbol
331
331
// We only need to check for primitives because derived value classes in arrays are always boxed.
332
332
else if sym.isPrimitiveValueClass then
@@ -781,14 +781,14 @@ class TypeErasure(sourceLanguage: SourceLanguage, semiEraseVCs: Boolean, isConst
781
781
782
782
private def eraseArray (tp : Type )(using Context ) = {
783
783
val defn .ArrayOf (elemtp) = tp : @ unchecked
784
- if ( isGenericArrayElement(elemtp, isScala2 = sourceLanguage.isScala2)) defn. ObjectType
785
- else
786
- try
787
- if sourceLanguage.isScala2 && (elemtp.isNullType || elemtp.isNothingType) then
788
- JavaArrayType (defn. ObjectType )
789
- else erasureFn(sourceLanguage, semiEraseVCs = false , isConstructor, isSymbol, inSigName)(elemtp) match
790
- case _ : WildcardType => WildcardType
791
- case elem => JavaArrayType (elem)
784
+ if isGenericArrayElement(elemtp, isScala2 = sourceLanguage.isScala2) then
785
+ defn. ObjectType
786
+ else if sourceLanguage.isScala2 && (elemtp.hiBound.isNullType || elemtp.hiBound.isNothingType) then
787
+ JavaArrayType (defn. ObjectType )
788
+ else
789
+ try erasureFn(sourceLanguage, semiEraseVCs = false , isConstructor, isSymbol, inSigName)(elemtp) match
790
+ case _ : WildcardType => WildcardType
791
+ case elem => JavaArrayType (elem)
792
792
catch case ex : Throwable =>
793
793
handleRecursive(" erase array type" , tp.show, ex)
794
794
}
0 commit comments