Skip to content

Commit 57912ff

Browse files
Fix #13455: Also consider sealed classes closed sums
1 parent 842323a commit 57912ff

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

compiler/src/dotty/tools/dotc/core/TypeComparer.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -2528,7 +2528,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
25282528

25292529
/** Can we enumerate all instantiations of this type? */
25302530
def isClosedSum(tp: Symbol): Boolean =
2531-
tp.is(Sealed) && tp.isOneOf(AbstractOrTrait) && !tp.hasAnonymousChild
2531+
tp.is(Sealed) && !tp.hasAnonymousChild
25322532

25332533
/** Splits a closed type into a disjunction of smaller types.
25342534
* It should hold that `tp` and `decompose(tp).reduce(_ or _)`

tests/pos/13455.scala

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
sealed class R
2+
3+
type X[T] = T match {
4+
case R => String
5+
case (z => r) => Int
6+
}
7+
def x[T]: X[T] = ???
8+
9+
def i(i0: Int): Unit = ???
10+
val a = i(x[Int => String])

0 commit comments

Comments
 (0)