Skip to content

Commit 51f67b4

Browse files
committed
Fix isBottomType
Need to widen before testing
1 parent 4c1e38e commit 51f67b4

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,11 +1175,13 @@ class Definitions {
11751175
def isBottomClassAfterErasure(cls: Symbol): Boolean = cls == NothingClass || cls == NullClass
11761176

11771177
def isBottomType(tp: Type): Boolean =
1178-
if (ctx.explicitNulls && !ctx.phase.erasedTypes) tp.isCombinedRef(NothingClass)
1179-
else isBottomTypeAfterErasure(tp)
1178+
val tpw = tp.widen
1179+
tpw.isCombinedRef(NothingClass)
1180+
|| tpw.isCombinedRef(NullClass) && (!ctx.explicitNulls || ctx.phase.erasedTypes)
11801181

11811182
def isBottomTypeAfterErasure(tp: Type): Boolean =
1182-
tp.isCombinedRef(NothingClass) || tp.isCombinedRef(NullClass)
1183+
val tpw = tp.widen
1184+
tpw.isCombinedRef(NothingClass) || tpw.isCombinedRef(NullClass)
11831185

11841186
/** Is a function class.
11851187
* - FunctionXXL

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1539,9 +1539,6 @@ object Types {
15391539
/** Is this (an alias of) the `scala.Null` type? */
15401540
final def isNullType(using Context) = isRef(defn.NullClass)
15411541

1542-
/** Is this (an alias of) the `scala.Null` or `scala.Nothing` type? */
1543-
final def isNullOrNothingType(using Context) = isNullType || isRef(defn.NothingClass)
1544-
15451542
/** The resultType of a LambdaType, or ExprType, the type itself for others */
15461543
def resultType(using Context): Type = this
15471544

0 commit comments

Comments
 (0)