diff --git a/compiler/src/dotty/tools/dotc/transform/PatternMatcher.scala b/compiler/src/dotty/tools/dotc/transform/PatternMatcher.scala index 1e95ca1618b2..1e16897081dd 100644 --- a/compiler/src/dotty/tools/dotc/transform/PatternMatcher.scala +++ b/compiler/src/dotty/tools/dotc/transform/PatternMatcher.scala @@ -814,11 +814,11 @@ object PatternMatcher { */ private def collectSwitchCases(scrutinee: Tree, plan: SeqPlan): List[(List[Tree], Plan)] = { def isSwitchableType(tpe: Type): Boolean = - (tpe isRef defn.IntClass) || - (tpe isRef defn.ByteClass) || - (tpe isRef defn.ShortClass) || - (tpe isRef defn.CharClass) || - (tpe isRef defn.StringClass) + (tpe <:< defn.IntType) || + (tpe <:< defn.ByteType) || + (tpe <:< defn.ShortType) || + (tpe <:< defn.CharType) || + (tpe <:< defn.StringType) val seen = mutable.Set[Any]() @@ -868,7 +868,7 @@ object PatternMatcher { (Nil, plan) :: Nil } - if (isSwitchableType(scrutinee.tpe.widen.widenSingletons())) recur(plan) + if (isSwitchableType(scrutinee.tpe)) recur(plan) else Nil } @@ -889,9 +889,8 @@ object PatternMatcher { */ val (primScrutinee, scrutineeTpe) = - val tpe = scrutinee.tpe.widen.widenSingletons() - if (tpe.isRef(defn.IntClass)) (scrutinee, defn.IntType) - else if (tpe.isRef(defn.StringClass)) (scrutinee, defn.StringType) + if (scrutinee.tpe <:< defn.IntType) (scrutinee, defn.IntType) + else if (scrutinee.tpe <:< defn.StringType) (scrutinee, defn.StringType) else (scrutinee.select(nme.toInt), defn.IntType) def primLiteral(lit: Tree): Tree =