Skip to content

Commit 50b03c0

Browse files
committed
Dealias and-types in canDecompose
For consistency with or-types.
1 parent 75c4f38 commit 50b03c0

File tree

1 file changed

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

1 file changed

+4
-3
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -476,11 +476,12 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
476476

477477
/** Abstract sealed types, or-types, Boolean and Java enums can be decomposed */
478478
def canDecompose(tp: Type): Boolean = {
479+
val dealiasedTp = tp.dealias
479480
val res = tp.classSymbol.is(allOf(Abstract, Sealed)) ||
480481
tp.classSymbol.is(allOf(Trait, Sealed)) ||
481-
tp.dealias.isInstanceOf[OrType] ||
482-
(tp.isInstanceOf[AndType] && {
483-
val and = tp.asInstanceOf[AndType]
482+
dealiasedTp.isInstanceOf[OrType] ||
483+
(dealiasedTp.isInstanceOf[AndType] && {
484+
val and = dealiasedTp.asInstanceOf[AndType]
484485
canDecompose(and.tp1) || canDecompose(and.tp2)
485486
}) ||
486487
tp =:= ctx.definitions.BooleanType ||

0 commit comments

Comments
 (0)