Skip to content

Commit b40122f

Browse files
committed
Space: Make isDecomposableToChildren ignore type constructors
1 parent 3c9117d commit b40122f

File tree

1 file changed

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

1 file changed

+5
-4
lines changed

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

+5-4
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ object SpaceEngine {
638638
// For instance, from i15029, `decompose((X | Y).Field[T]) = [X.Field[T], Y.Field[T]]`.
639639
parts.map(tp.derivedAppliedType(_, targs))
640640

641-
case tp if tp.classSymbol.isDecomposableToChildren =>
641+
case tp if tp.isDecomposableToChildren =>
642642
def getChildren(sym: Symbol): List[Symbol] =
643643
sym.children.flatMap { child =>
644644
if child eq sym then List(sym) // i3145: sealed trait Baz, val x = new Baz {}, Baz.children returns Baz...
@@ -674,8 +674,8 @@ object SpaceEngine {
674674
rec(tp, Nil)
675675
}
676676

677-
extension (cls: Symbol)
678-
/** A type is decomposable to children if it's sealed,
677+
extension (tp: Type)
678+
/** A type is decomposable to children if it has a simple kind, it's sealed,
679679
* abstract (or a trait) - so its not a sealed concrete class that can be instantiated on its own,
680680
* has no anonymous children, which we wouldn't be able to name as counter-examples,
681681
* but does have children.
@@ -684,7 +684,8 @@ object SpaceEngine {
684684
* A sealed trait with subclasses that then get removed after `refineUsingParent`, decomposes to the empty list.
685685
* So that's why we consider whether a type has children. */
686686
def isDecomposableToChildren(using Context): Boolean =
687-
cls.is(Sealed) && cls.isOneOf(AbstractOrTrait) && !cls.hasAnonymousChild && cls.children.nonEmpty
687+
val cls = tp.classSymbol
688+
tp.hasSimpleKind && cls.is(Sealed) && cls.isOneOf(AbstractOrTrait) && !cls.hasAnonymousChild && cls.children.nonEmpty
688689

689690
val ListOfNoType = List(NoType)
690691
val ListOfTypNoType = ListOfNoType.map(Typ(_, decomposed = true))

0 commit comments

Comments
 (0)