Skip to content

Commit e9fd333

Browse files
authored
Merge pull request #2424 from dotty-staging/fix-2363
Fix #2363: better handle extractors in exhaustivity check
2 parents 5d8cee3 + 1e695ea commit e9fd333

23 files changed

+297
-66
lines changed

compiler/src/dotty/tools/dotc/ast/Desugar.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,7 @@ object desugar {
859859
case IdPattern(named, tpt) =>
860860
Function(derivedValDef(pat, named, tpt, EmptyTree, Modifiers(Param)) :: Nil, body)
861861
case _ =>
862-
makeCaseLambda(CaseDef(pat, EmptyTree, body) :: Nil, unchecked = false)
862+
makeCaseLambda(CaseDef(pat, EmptyTree, body) :: Nil)
863863
}
864864

865865
/** If `pat` is not an Identifier, a Typed(Ident, _), or a Bind, wrap

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -351,15 +351,17 @@ class PatternMatcher extends MiniPhaseTransform with DenotTransformer {
351351
/* (Nil, body) means that `body` is the default case
352352
* It's a bit hacky but it simplifies manipulations.
353353
*/
354-
def extractSwitchCase(treeMakers: List[TreeMaker]): (List[Int], BodyTreeMaker) = treeMakers match {
354+
def extractSwitchCase(treeMakers: List[TreeMaker]): (List[Int], BodyTreeMaker) = (treeMakers: @unchecked) match {
355355
// case 5 =>
356356
case List(IntEqualityTestTreeMaker(intValue), body: BodyTreeMaker) =>
357357
(List(intValue), body)
358358

359359
// case 5 | 6 =>
360360
case List(AlternativesTreeMaker(_, alts, _), body: BodyTreeMaker) =>
361-
val intValues = alts.map {
362-
case List(IntEqualityTestTreeMaker(intValue)) => intValue
361+
val intValues = alts.map { alt =>
362+
(alt: @unchecked) match {
363+
case List(IntEqualityTestTreeMaker(intValue)) => intValue
364+
}
363365
}
364366
(intValues, body)
365367

0 commit comments

Comments
 (0)