@@ -835,7 +835,7 @@ object SpaceEngine {
835
835
/** Return the underlying type of non-module, non-constant, non-enum case singleton types.
836
836
* Also widen ExprType to its result type, and rewrap any annotation wrappers.
837
837
* For example, with `val opt = None`, widen `opt.type` to `None.type`. */
838
- def toUnderlying (tp : Type )(using Context ): Type = trace(i " toUnderlying( $tp) " )(tp match {
838
+ def toUnderlying (tp : Type )(using Context ): Type = trace(i " toUnderlying( $tp ${tp.className} ) " )(tp match {
839
839
case _ : ConstantType => tp
840
840
case tp : TermRef if tp.symbol.is(Module ) => tp
841
841
case tp : TermRef if tp.symbol.isAllOf(EnumCase ) => tp
@@ -846,7 +846,7 @@ object SpaceEngine {
846
846
})
847
847
848
848
def checkExhaustivity (m : Match )(using Context ): Unit = trace(i " checkExhaustivity( $m) " ) {
849
- val selTyp = toUnderlying(m.selector.tpe).dealias
849
+ val selTyp = toUnderlying(m.selector.tpe.stripNull() ).dealias
850
850
val targetSpace = trace(i " targetSpace( $selTyp) " )(project(selTyp))
851
851
852
852
val patternSpace = Or (m.cases.foldLeft(List .empty[Space ]) { (acc, x) =>
@@ -879,7 +879,7 @@ object SpaceEngine {
879
879
def checkReachability (m : Match )(using Context ): Unit = trace(i " checkReachability( $m) " ) {
880
880
val cases = m.cases.toIndexedSeq
881
881
882
- val selTyp = toUnderlying(m.selector.tpe).dealias
882
+ val selTyp = toUnderlying(m.selector.tpe.stripNull() ).dealias
883
883
884
884
val isNullable = selTyp.classSymbol.isNullableClass
885
885
val targetSpace = trace(i " targetSpace( $selTyp) " )(if isNullable
0 commit comments