Skip to content

Commit 9715eed

Browse files
authored
Short-circuit isCheckable with classSymbol (#19634)
2 parents 18be8d1 + eff3424 commit 9715eed

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,7 @@ object SpaceEngine {
773773
}
774774

775775
private def exhaustivityCheckable(sel: Tree)(using Context): Boolean = {
776-
val seen = collection.mutable.Set.empty[Type]
776+
val seen = collection.mutable.Set.empty[Symbol]
777777

778778
// Possible to check everything, but be compatible with scalac by default
779779
def isCheckable(tp: Type): Boolean =
@@ -789,7 +789,7 @@ object SpaceEngine {
789789
tpw.isRef(defn.BooleanClass) ||
790790
classSym.isAllOf(JavaEnum) ||
791791
classSym.is(Case) && {
792-
if seen.add(tpw) then productSelectorTypes(tpw, sel.srcPos).exists(isCheckable(_))
792+
if seen.add(classSym) then productSelectorTypes(tpw, sel.srcPos).exists(isCheckable(_))
793793
else true // recursive case class: return true and other members can still fail the check
794794
}
795795

tests/pos/i19433.scala

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// minimised from github.com/Adam-Vandervorst/CZ2
2+
3+
import scala.collection.mutable
4+
5+
private trait EMImpl[V, F[_]]
6+
7+
case class EM[V2](apps: ExprMap[ExprMap[V2]]) extends EMImpl[V2, EM]:
8+
def collect[W](pf: PartialFunction[V2, W]): Unit =
9+
val apps1 = apps.collect(_.collect(pf))
10+
11+
case class ExprMap[V](var em: EM[V] = null) extends EMImpl[V, ExprMap]:
12+
def collect[W](pf: PartialFunction[V, W]): ExprMap[W] = ??? // was: StackOverflow in isCheckable

0 commit comments

Comments
 (0)