@@ -247,15 +247,15 @@ object TypeErasure {
247
247
def isUnboundedGeneric (tp : Type )(using Context ): Boolean = tp.dealias match {
248
248
case tp : TypeRef if ! tp.symbol.isOpaqueAlias =>
249
249
! tp.symbol.isClass &&
250
- ! classify(tp).derivesFrom(defn.ObjectClass ) &&
250
+ ! classify(tp).derivesFrom(defn.ObjectClass , afterErasure = true ) &&
251
251
! tp.symbol.is(JavaDefined )
252
252
case tp : TypeParamRef =>
253
- ! classify(tp).derivesFrom(defn.ObjectClass ) &&
253
+ ! classify(tp).derivesFrom(defn.ObjectClass , afterErasure = true ) &&
254
254
! tp.binder.resultType.isJavaMethod
255
255
case tp : TypeAlias => isUnboundedGeneric(tp.alias)
256
256
case tp : TypeBounds =>
257
257
val upper = classify(tp.hi)
258
- ! upper.derivesFrom(defn.ObjectClass ) &&
258
+ ! upper.derivesFrom(defn.ObjectClass , afterErasure = true ) &&
259
259
! upper.isPrimitiveValueType
260
260
case tp : TypeProxy => isUnboundedGeneric(tp.translucentSuperType)
261
261
case tp : AndType => isUnboundedGeneric(tp.tp1) && isUnboundedGeneric(tp.tp2)
@@ -292,8 +292,8 @@ object TypeErasure {
292
292
// We need to short-circuit this case here because the regular lub logic below
293
293
// relies on the class hierarchy, which doesn't properly capture `Null`s subtyping
294
294
// behaviour.
295
- if (tp1.isBottomTypeAfterErasure && tp2.derivesFrom(defn.ObjectClass )) return tp2
296
- if (tp2.isBottomTypeAfterErasure && tp1.derivesFrom(defn.ObjectClass )) return tp1
295
+ if (tp1.isBottomTypeAfterErasure && tp2.derivesFrom(defn.ObjectClass , afterErasure = true )) return tp2
296
+ if (tp2.isBottomTypeAfterErasure && tp1.derivesFrom(defn.ObjectClass , afterErasure = true )) return tp1
297
297
tp1 match {
298
298
case JavaArrayType (elem1) =>
299
299
import dotty .tools .dotc .transform .TypeUtils ._
@@ -516,8 +516,7 @@ class TypeErasure(isJava: Boolean, semiEraseVCs: Boolean, isConstructor: Boolean
516
516
}
517
517
518
518
private def eraseArray (tp : Type )(using Context ) = {
519
- val defn .ArrayOf (elemtp0) = tp
520
- val elemtp = if ctx.explicitNulls then elemtp0.stripNull else elemtp0
519
+ val defn .ArrayOf (elemtp) = tp
521
520
if classify(elemtp).derivesFrom(defn.NullClass ) then JavaArrayType (defn.ObjectType )
522
521
else if isUnboundedGeneric(elemtp) && ! isJava then defn.ObjectType
523
522
else JavaArrayType (erasureFn(isJava, semiEraseVCs = false , isConstructor, wildcardOK)(elemtp))
0 commit comments