Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions compiler/src/dotty/tools/dotc/core/TypeErasure.scala
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,15 @@ class TypeErasure(sourceLanguage: SourceLanguage, semiEraseVCs: Boolean, isConst
if e1.isInstanceOf[WildcardType] || e2.isInstanceOf[WildcardType] then WildcardType
else erasedGlb(e1, e2)
case OrType(tp1, tp2) =>
if isSymbol && sourceLanguage.isScala2 && ctx.settings.scalajs.value then
val e1 = this(tp1)
val e2 = this(tp2)
val result = if e1.isInstanceOf[WildcardType] || e2.isInstanceOf[WildcardType]
then WildcardType
else TypeComparer.orType(e1, e2, isErased = true)
def isNullStripped =
tp2.isNullType && e1.derivesFrom(defn.ObjectClass)
|| tp1.isNullType && e2.derivesFrom(defn.ObjectClass)
if isSymbol && sourceLanguage.isScala2 && ctx.settings.scalajs.value && !isNullStripped then
// In Scala2Unpickler we unpickle Scala.js pseudo-unions as if they were
// real unions, but we must still erase them as Scala 2 would to emit
// the correct signatures in SJSIR.
Expand All @@ -692,11 +700,7 @@ class TypeErasure(sourceLanguage: SourceLanguage, semiEraseVCs: Boolean, isConst
// impact on overriding relationships so it's best to leave them
// alone (and this doesn't impact the SJSIR we generate).
JSDefinitions.jsdefn.PseudoUnionType
else
val e1 = this(tp1)
val e2 = this(tp2)
if e1.isInstanceOf[WildcardType] || e2.isInstanceOf[WildcardType] then WildcardType
else TypeComparer.orType(e1, e2, isErased = true)
else result
case tp: MethodType =>
def paramErasure(tpToErase: Type) =
erasureFn(sourceLanguage, semiEraseVCs, isConstructor, isSymbol, inSigName = false)(tpToErase)
Expand Down
Loading