@@ -308,9 +308,7 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
308
308
309
309
override def intersectUnrelatedAtomicTypes (tp1 : Type , tp2 : Type ): Space = {
310
310
// Precondition: !isSubType(tp1, tp2) && !isSubType(tp2, tp1).
311
- if (ctx.explicitNulls) {
312
- // No additional checks required: since subtyping already reflects nullability.
313
- } else if (tp1.isNullType || tp2.isNullType) {
311
+ if (! ctx.explicitNulls && (tp1.isNullType || tp2.isNullType)) {
314
312
// Since projections of types don't include null, intersection with null is empty.
315
313
return Empty
316
314
}
@@ -791,20 +789,14 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
791
789
}
792
790
793
791
// if last case is `_` and only matches `null`, produce a warning
794
- if (i == cases.length - 1 && ! isNullLit(pat) ) {
792
+ // If explicit nulls are enabled, this check isn't needed because most of the cases
793
+ // that would trigger it would also trigger unreachability warnings.
794
+ if (! ctx.explicitNulls && i == cases.length - 1 && ! isNullLit(pat) ) {
795
795
val simpl = simplify(minus(covered, prevs))
796
- if (ctx.explicitNulls) {
797
- simpl match {
798
- case space if isNullSpace(space) =>
799
- ctx.warning(MatchCaseOnlyNullWarning (), pat.sourcePos)
800
- case _ =>
801
- }
802
- } else {
803
- simpl match {
804
- case Typ (`constantNullType`, _) =>
805
- ctx.warning(MatchCaseOnlyNullWarning (), pat.sourcePos)
806
- case _ =>
807
- }
796
+ simpl match {
797
+ case Typ (`constantNullType`, _) =>
798
+ ctx.warning(MatchCaseOnlyNullWarning (), pat.sourcePos)
799
+ case _ =>
808
800
}
809
801
}
810
802
}
0 commit comments