Skip to content

Commit 81423fe

Browse files
committed
Slighly faster phantom erasure checks.
1 parent 6acd0aa commit 81423fe

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -981,8 +981,8 @@ class Definitions {
981981
cls
982982
}
983983

984-
def isPhantomAnyClass(sym: Symbol)(implicit ctx: Context): Boolean =
985-
sym.name == tpnme.Any && (sym.owner eq PhantomClass)
984+
def isPhantomAnyOrNothingClass(sym: Symbol)(implicit ctx: Context): Boolean =
985+
(sym.name == tpnme.Any || sym.name == tpnme.Nothing) && (sym.owner eq PhantomClass)
986986

987987
def isPhantomNothingClass(sym: Symbol)(implicit ctx: Context): Boolean =
988988
sym.name == tpnme.Nothing && (sym.owner eq PhantomClass)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ 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.isPhantomAnyClass(tp.symbol) || defn.isPhantomNothingClass(tp.symbol)) defn.ErasedPhantomType
367+
else if (defn.isPhantomAnyOrNothingClass(tp.symbol)) defn.ErasedPhantomType
368368
else eraseNormalClassRef(tp)
369369
case tp: RefinedType =>
370370
val parent = tp.parent
@@ -507,7 +507,7 @@ class TypeErasure(isJava: Boolean, semiEraseVCs: Boolean, isConstructor: Boolean
507507
}
508508
if (defn.isSyntheticFunctionClass(sym))
509509
sigName(defn.erasedFunctionType(sym))
510-
else if (defn.isPhantomAnyClass(tp.symbol) || defn.isPhantomNothingClass(tp.symbol))
510+
else if (defn.isPhantomAnyOrNothingClass(tp.symbol))
511511
sigName(defn.ErasedPhantomType)
512512
else
513513
normalizeClass(sym.asClass).fullName.asTypeName

0 commit comments

Comments
 (0)