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