Skip to content

Commit 9388ce4

Browse files
committed
Slighly faster phantom erasure checks.
1 parent f6c7571 commit 9388ce4

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
@@ -980,8 +980,8 @@ class Definitions {
980980
cls
981981
}
982982

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

986986
def isPhantomNothingClass(sym: Symbol)(implicit ctx: Context): Boolean =
987987
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)