Skip to content

Commit b704197

Browse files
committed
Completely erase scala.Phantom
Previously the parents in the trees kept a reference to Phantom.
1 parent 7a3f880 commit b704197

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

compiler/src/dotty/tools/dotc/core/TypeErasure.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,8 @@ class TypeErasure(isJava: Boolean, semiEraseVCs: Boolean, isConstructor: Boolean
364364
else if (semiEraseVCs && isDerivedValueClass(sym)) eraseDerivedValueClassRef(tp)
365365
else if (sym == defn.ArrayClass) apply(tp.appliedTo(TypeBounds.empty)) // i966 shows that we can hit a raw Array type.
366366
else if (defn.isSyntheticFunctionClass(sym)) defn.erasedFunctionType(sym)
367-
else if (defn.isPhantomTerminalClass(tp.symbol)) PhantomErasure.erasedPhantomType
367+
else if (defn.isPhantomTerminalClass(sym)) PhantomErasure.erasedPhantomType
368+
else if (sym eq defn.PhantomClass) defn.ObjectType // To erase the definitions of Phantom.{assume, Any, Nothing}
368369
else eraseNormalClassRef(tp)
369370
case tp: RefinedType =>
370371
val parent = tp.parent
@@ -404,8 +405,7 @@ class TypeErasure(isJava: Boolean, semiEraseVCs: Boolean, isConstructor: Boolean
404405
case tr :: trs1 =>
405406
assert(!tr.classSymbol.is(Trait), cls)
406407
val tr1 = if (cls is Trait) defn.ObjectType else tr
407-
// We remove the Phantom trait to erase the definitions of Phantom.{assume, Any, Nothing}
408-
tr1 :: trs1.filterNot(x => x.isRef(defn.ObjectClass) || x.isRef(defn.PhantomClass))
408+
tr1 :: trs1.filterNot(_ isRef defn.ObjectClass)
409409
case nil => nil
410410
}
411411
val erasedDecls = decls.filteredScope(sym => !sym.isType || sym.isClass)

0 commit comments

Comments
 (0)