Skip to content

Commit dc70b77

Browse files
Backport "Short-circuit isCheckable with classSymbol" to LTS (#20942)
Backports #19634 to the LTS branch. PR submitted by the release tooling. [skip ci]
2 parents 56079bf + dfc78fa commit dc70b77

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
@@ -775,7 +775,7 @@ object SpaceEngine {
775775
}
776776

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

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

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)