@@ -596,8 +596,8 @@ class TypeErasure(sourceLanguage: SourceLanguage, semiEraseVCs: Boolean, isConst
596
596
* will be returned.
597
597
*
598
598
* In all other situations, |T| will be computed as follow:
599
- * - For a refined type scala.Array+ [T]:
600
- * - if T is Nothing or Null, []Object
599
+ * - For a refined type scala.Array[T]:
600
+ * - {Scala 2} if T is Nothing or Null, []Object
601
601
* - otherwise, if T <: Object, []|T|
602
602
* - otherwise, if T is a type parameter coming from Java, []Object
603
603
* - otherwise, Object
@@ -783,10 +783,12 @@ class TypeErasure(sourceLanguage: SourceLanguage, semiEraseVCs: Boolean, isConst
783
783
val defn .ArrayOf (elemtp) = tp : @ unchecked
784
784
if (isGenericArrayElement(elemtp, isScala2 = sourceLanguage.isScala2)) defn.ObjectType
785
785
else
786
- try
787
- val eElem = erasureFn(sourceLanguage, semiEraseVCs = false , isConstructor, isSymbol, inSigName)(elemtp)
788
- if eElem.isInstanceOf [WildcardType ] then WildcardType
789
- else JavaArrayType (eElem)
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)
790
792
catch case ex : Throwable =>
791
793
handleRecursive(" erase array type" , tp.show, ex)
792
794
}
0 commit comments