Skip to content

Commit 83d46ad

Browse files
dwickernWojciechMazur
authored andcommitted
replace widen with <:<
[Cherry-picked 7279bf7]
1 parent ae4f6d9 commit 83d46ad

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

compiler/src/dotty/tools/dotc/transform/PatternMatcher.scala

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -805,11 +805,11 @@ object PatternMatcher {
805805
*/
806806
private def collectSwitchCases(scrutinee: Tree, plan: SeqPlan): List[(List[Tree], Plan)] = {
807807
def isSwitchableType(tpe: Type): Boolean =
808-
(tpe isRef defn.IntClass) ||
809-
(tpe isRef defn.ByteClass) ||
810-
(tpe isRef defn.ShortClass) ||
811-
(tpe isRef defn.CharClass) ||
812-
(tpe isRef defn.StringClass)
808+
(tpe <:< defn.IntType) ||
809+
(tpe <:< defn.ByteType) ||
810+
(tpe <:< defn.ShortType) ||
811+
(tpe <:< defn.CharType) ||
812+
(tpe <:< defn.StringType)
813813

814814
val seen = mutable.Set[Any]()
815815

@@ -859,7 +859,7 @@ object PatternMatcher {
859859
(Nil, plan) :: Nil
860860
}
861861

862-
if (isSwitchableType(scrutinee.tpe.widen.widenSingletons())) recur(plan)
862+
if (isSwitchableType(scrutinee.tpe)) recur(plan)
863863
else Nil
864864
}
865865

@@ -880,9 +880,8 @@ object PatternMatcher {
880880
*/
881881

882882
val (primScrutinee, scrutineeTpe) =
883-
val tpe = scrutinee.tpe.widen.widenSingletons()
884-
if (tpe.isRef(defn.IntClass)) (scrutinee, defn.IntType)
885-
else if (tpe.isRef(defn.StringClass)) (scrutinee, defn.StringType)
883+
if (scrutinee.tpe <:< defn.IntType) (scrutinee, defn.IntType)
884+
else if (scrutinee.tpe <:< defn.StringType) (scrutinee, defn.StringType)
886885
else (scrutinee.select(nme.toInt), defn.IntType)
887886

888887
def primLiteral(lit: Tree): Tree =

0 commit comments

Comments
 (0)