Skip to content

Commit 979d097

Browse files
authored
Merge pull request #8733 from dotty-staging/fix-8726
Fix #8726: test Boolean match with subtype check
2 parents 9a4feff + b7b6120 commit 979d097

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

compiler/src/dotty/tools/dotc/transform/PatternMatcher.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ object PatternMatcher {
319319

320320
if (isSyntheticScala2Unapply(unapp.symbol) && caseAccessors.length == args.length)
321321
matchArgsPlan(caseAccessors.map(ref(scrutinee).select(_)), args, onSuccess)
322-
else if (unapp.tpe.widenSingleton.isRef(defn.BooleanClass))
322+
else if (unapp.tpe <:< (defn.BooleanType))
323323
TestPlan(GuardTest, unapp, unapp.span, onSuccess)
324324
else
325325
letAbstract(unapp) { unappResult =>

tests/run/i8726.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
case class A(a: Int)
2+
object C { def unapply(a: A): true | true = true }
3+
4+
@main
5+
def Test = (A(1): A | A) match { case C() => "OK" }

0 commit comments

Comments
 (0)