@@ -681,7 +681,15 @@ class TypeErasure(sourceLanguage: SourceLanguage, semiEraseVCs: Boolean, isConst
681
681
if e1.isInstanceOf [WildcardType ] || e2.isInstanceOf [WildcardType ] then WildcardType
682
682
else erasedGlb(e1, e2)
683
683
case OrType (tp1, tp2) =>
684
- if isSymbol && sourceLanguage.isScala2 && ctx.settings.scalajs.value then
684
+ val e1 = this (tp1)
685
+ val e2 = this (tp2)
686
+ val result = if e1.isInstanceOf [WildcardType ] || e2.isInstanceOf [WildcardType ]
687
+ then WildcardType
688
+ else TypeComparer .orType(e1, e2, isErased = true )
689
+ def isNullStripped =
690
+ tp2.isNullType && e1.derivesFrom(defn.ObjectClass )
691
+ || tp2.isNullType && e2.derivesFrom(defn.ObjectClass )
692
+ if isSymbol && sourceLanguage.isScala2 && ctx.settings.scalajs.value && ! isNullStripped then
685
693
// In Scala2Unpickler we unpickle Scala.js pseudo-unions as if they were
686
694
// real unions, but we must still erase them as Scala 2 would to emit
687
695
// the correct signatures in SJSIR.
@@ -692,11 +700,7 @@ class TypeErasure(sourceLanguage: SourceLanguage, semiEraseVCs: Boolean, isConst
692
700
// impact on overriding relationships so it's best to leave them
693
701
// alone (and this doesn't impact the SJSIR we generate).
694
702
JSDefinitions .jsdefn.PseudoUnionType
695
- else
696
- val e1 = this (tp1)
697
- val e2 = this (tp2)
698
- if e1.isInstanceOf [WildcardType ] || e2.isInstanceOf [WildcardType ] then WildcardType
699
- else TypeComparer .orType(e1, e2, isErased = true )
703
+ else result
700
704
case tp : MethodType =>
701
705
def paramErasure (tpToErase : Type ) =
702
706
erasureFn(sourceLanguage, semiEraseVCs, isConstructor, isSymbol, inSigName = false )(tpToErase)
0 commit comments