Skip to content

Commit ffd2b97

Browse files
committed
Avoid type cast
1 parent f437478 commit ffd2b97

File tree

1 file changed

+6
-6
lines changed
  • compiler/src/dotty/tools/dotc/transform/patmat

1 file changed

+6
-6
lines changed

compiler/src/dotty/tools/dotc/transform/patmat/Space.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ trait SpaceLogic {
105105
def signature(unapp: TermRef, scrutineeTp: Type, argLen: Int): List[Type]
106106

107107
/** Get components of decomposable types */
108-
def decompose(tp: Type): List[Space]
108+
def decompose(tp: Type): List[Typ]
109109

110110
/** Whether the extractor covers the given type */
111111
def covers(unapp: TermRef, scrutineeTp: Type): Boolean
@@ -335,7 +335,7 @@ class SpaceEngine(using Context) extends SpaceLogic {
335335
case _ => false
336336
}
337337

338-
override def intersectUnrelatedAtomicTypes(tp1: Type, tp2: Type): Space = trace(s"atomic intersection: ${AndType(tp1, tp2).show}", debug) {
338+
override def intersectUnrelatedAtomicTypes(tp1: Type, tp2: Type): Empty.type | Typ = trace(s"atomic intersection: ${AndType(tp1, tp2).show}", debug) {
339339
// Precondition: !isSubType(tp1, tp2) && !isSubType(tp2, tp1).
340340
if (!ctx.explicitNulls && (tp1.isNullType || tp2.isNullType)) {
341341
// Since projections of types don't include null, intersection with null is empty.
@@ -589,11 +589,11 @@ class SpaceEngine(using Context) extends SpaceLogic {
589589
}
590590

591591
/** Decompose a type into subspaces -- assume the type can be decomposed */
592-
def decompose(tp: Type): List[Space] =
592+
def decompose(tp: Type): List[Typ] =
593593
tp.dealias match {
594594
case AndType(tp1, tp2) =>
595-
def decomposeComponent(tpA: Type, tpB: Type) =
596-
decompose(tpA).asInstanceOf[List[Typ]].flatMap {
595+
def decomposeComponent(tpA: Type, tpB: Type): List[Typ] =
596+
decompose(tpA).flatMap {
597597
case Typ(tp, _) =>
598598
if tp <:< tpB then
599599
Typ(tp, decomposed = true) :: Nil
@@ -602,7 +602,7 @@ class SpaceEngine(using Context) extends SpaceLogic {
602602
else
603603
intersectUnrelatedAtomicTypes(tp, tpB) match
604604
case Empty => Nil
605-
case space => List(space)
605+
case typ: Typ => List(typ)
606606
}
607607

608608
if canDecompose(tp1) then

0 commit comments

Comments
 (0)