@@ -112,6 +112,8 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
112
112
true
113
113
}
114
114
115
+ private def isBottom (tp : Type ) = tp.widen.isRef(NothingClass )
116
+
115
117
protected def gadtBounds (sym : Symbol )(using Context ) = ctx.gadt.bounds(sym)
116
118
protected def gadtAddLowerBound (sym : Symbol , b : Type ): Boolean = ctx.gadt.addBound(sym, b, isUpper = false )
117
119
protected def gadtAddUpperBound (sym : Symbol , b : Type ): Boolean = ctx.gadt.addBound(sym, b, isUpper = true )
@@ -371,7 +373,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
371
373
thirdTry
372
374
case tp1 : TypeParamRef =>
373
375
def flagNothingBound = {
374
- if (! frozenConstraint && tp2.isRef( NothingClass ) && state.isGlobalCommittable) {
376
+ if (! frozenConstraint && isBottom(tp2 ) && state.isGlobalCommittable) {
375
377
def msg = s " !!! instantiated to Nothing: $tp1, constraint = ${constraint.show}"
376
378
if (Config .failOnInstantiationToNothing) assert(false , msg)
377
379
else report.log(msg)
@@ -479,7 +481,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
479
481
case _ => false
480
482
}) ||
481
483
narrowGADTBounds(tp2, tp1, approx, isUpper = false )) &&
482
- { tp1.isRef( NothingClass ) || GADTusage (tp2.symbol) }
484
+ { isBottom(tp1 ) || GADTusage (tp2.symbol) }
483
485
}
484
486
isSubApproxHi(tp1, info2.lo) || compareGADT || tryLiftedToThis2 || fourthTry
485
487
@@ -488,7 +490,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
488
490
if (cls2.isClass)
489
491
if (cls2.typeParams.isEmpty) {
490
492
if (cls2 eq AnyKindClass ) return true
491
- if (tp1.isRef( NothingClass )) return true
493
+ if (isBottom(tp1 )) return true
492
494
if (tp1.isLambdaSub) return false
493
495
// Note: We would like to replace this by `if (tp1.hasHigherKind)`
494
496
// but right now we cannot since some parts of the standard library rely on the
@@ -1872,8 +1874,8 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
1872
1874
if (tp1 eq tp2) tp1
1873
1875
else if (! tp1.exists) tp2
1874
1876
else if (! tp2.exists) tp1
1875
- else if tp1.isAny && ! tp2.isLambdaSub || tp1.isAnyKind || tp2.isRef( NothingClass ) then tp2
1876
- else if tp2.isAny && ! tp1.isLambdaSub || tp2.isAnyKind || tp1.isRef( NothingClass ) then tp1
1877
+ else if tp1.isAny && ! tp2.isLambdaSub || tp1.isAnyKind || isBottom(tp2 ) then tp2
1878
+ else if tp2.isAny && ! tp1.isLambdaSub || tp2.isAnyKind || isBottom(tp1 ) then tp1
1877
1879
else tp2 match { // normalize to disjunctive normal form if possible.
1878
1880
case tp2 : LazyRef =>
1879
1881
glb(tp1, tp2.ref)
@@ -1925,8 +1927,8 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
1925
1927
if (tp1 eq tp2) tp1
1926
1928
else if (! tp1.exists) tp1
1927
1929
else if (! tp2.exists) tp2
1928
- else if tp1.isAny && ! tp2.isLambdaSub || tp1.isAnyKind || tp2.isRef( NothingClass ) then tp1
1929
- else if tp2.isAny && ! tp1.isLambdaSub || tp2.isAnyKind || tp1.isRef( NothingClass ) then tp2
1930
+ else if tp1.isAny && ! tp2.isLambdaSub || tp1.isAnyKind || isBottom(tp2 ) then tp1
1931
+ else if tp2.isAny && ! tp1.isLambdaSub || tp2.isAnyKind || isBottom(tp1 ) then tp2
1930
1932
else
1931
1933
def mergedLub (tp1 : Type , tp2 : Type ): Type = {
1932
1934
tp1.atoms match
0 commit comments