Skip to content

Commit b8e05d5

Browse files
committed
Add isBottomType/Class tests to Definitions
1 parent 6cb2a3b commit b8e05d5

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,12 @@ class Definitions {
588588
name.startsWith(prefix) && name.drop(prefix.length).forall(_.isDigit)
589589
}
590590

591+
def isBottomClass(cls: Symbol) = cls == NothingClass || cls == NullClass
592+
def isBottomType(tp: Type) = tp match {
593+
case tp: TypeRef => isBottomClass(tp.symbol)
594+
case _ => false
595+
}
596+
591597
def isFunctionClass(cls: Symbol) = isVarArityClass(cls, tpnme.Function)
592598
def isAbstractFunctionClass(cls: Symbol) = isVarArityClass(cls, tpnme.AbstractFunction)
593599
def isTupleClass(cls: Symbol) = isVarArityClass(cls, tpnme.Tuple)

src/dotty/tools/dotc/typer/Inferencing.scala

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ object Inferencing {
8989
val minimize =
9090
variance >= 0 && !(
9191
force == ForceDegree.noBottom &&
92-
isBottomType(ctx.typeComparer.approximation(tvar.origin, fromBelow = true)))
92+
defn.isBottomType(ctx.typeComparer.approximation(tvar.origin, fromBelow = true)))
9393
if (minimize) instantiate(tvar, fromBelow = true)
9494
else toMaximize = true
9595
}
@@ -173,9 +173,6 @@ object Inferencing {
173173
approxAbove - approxBelow
174174
}
175175

176-
def isBottomType(tp: Type)(implicit ctx: Context) =
177-
tp == defn.NothingType || tp == defn.NullType
178-
179176
/** Recursively widen and also follow type declarations and type aliases. */
180177
def widenForMatchSelector(tp: Type)(implicit ctx: Context): Type = tp.widen match {
181178
case tp: TypeRef if !tp.symbol.isClass => widenForMatchSelector(tp.info.bounds.hi)

0 commit comments

Comments
 (0)