Skip to content

Commit 4269780

Browse files
committed
Always assume two TypeTest[S, T].unapply are the same
if they are equivalent in types.
1 parent 2666bae commit 4269780

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,9 @@ class SpaceEngine(using Context) extends SpaceLogic {
521521
}
522522

523523
def isSameUnapply(tp1: TermRef, tp2: TermRef): Boolean =
524-
tp1.prefix.isStable && tp2.prefix.isStable && tp1 =:= tp2
524+
// always assume two TypeTest[S, T].unapply are the same if they are equal in types
525+
(tp1.prefix.isStable && tp2.prefix.isStable || tp1.symbol == defn.TypeTest_unapply)
526+
&& tp1 =:= tp2
525527

526528
/** Parameter types of the case class type `tp`. Adapted from `unapplyPlan` in patternMatcher */
527529
def signature(unapp: TermRef, scrutineeTp: Type, argLen: Int): List[Type] = {

tests/patmat/i12020.check

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
19: Pattern Match Exhaustivity: _: TypeDef

0 commit comments

Comments
 (0)