Skip to content

Commit

Permalink
Fix scala#13455: Also consider sealed classes closed sums
Browse files Browse the repository at this point in the history
  • Loading branch information
OlivierBlanvillain authored and olsdavis committed Apr 4, 2022
1 parent 088d43e commit 7df5c92
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/TypeComparer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2528,7 +2528,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling

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

/** Splits a closed type into a disjunction of smaller types.
* It should hold that `tp` and `decompose(tp).reduce(_ or _)`
Expand Down
10 changes: 10 additions & 0 deletions tests/pos/13455.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
sealed class R

type X[T] = T match {
case R => String
case (z => r) => Int
}
def x[T]: X[T] = ???

def i(i0: Int): Unit = ???
val a = i(x[Int => String])

0 comments on commit 7df5c92

Please sign in to comment.