Skip to content

Commit 37f4855

Browse files
committed
Fix #12602: All sealed classes can be deecomposed
1 parent 9a0182a commit 37f4855

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -659,10 +659,7 @@ class SpaceEngine(using Context) extends SpaceLogic {
659659
case and: AndType => canDecompose(and.tp1) || canDecompose(and.tp2)
660660
case _ =>
661661
val cls = tp.classSymbol
662-
cls.is(Sealed)
663-
&& cls.isOneOf(AbstractOrTrait)
664-
&& !cls.hasAnonymousChild
665-
&& cls.children.nonEmpty
662+
cls.is(Sealed) && !cls.hasAnonymousChild
666663
|| cls.isAllOf(JavaEnumTrait)
667664
|| tp.isRef(defn.BooleanClass)
668665
|| tp.isRef(defn.UnitClass)
@@ -846,6 +843,9 @@ class SpaceEngine(using Context) extends SpaceLogic {
846843

847844
if (!exhaustivityCheckable(sel)) return
848845

846+
debug.println("checking " + _match.show)
847+
debug.println("selTyp = " + selTyp.show)
848+
849849
val patternSpace = Or(cases.foldLeft(List.empty[Space]) { (acc, x) =>
850850
val space = if (x.guard.isEmpty) project(x.pat) else Empty
851851
debug.println(s"${x.pat.show} ====> ${show(space)}")

tests/patmat/i12602.scala

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
sealed abstract class Foo[T]
2+
object Foo extends Foo[Nothing]

0 commit comments

Comments
 (0)