diff --git a/src/compiler/scala/tools/nsc/transform/patmat/MatchAnalysis.scala b/src/compiler/scala/tools/nsc/transform/patmat/MatchAnalysis.scala index ad11645b81e7..091eccfd3d96 100644 --- a/src/compiler/scala/tools/nsc/transform/patmat/MatchAnalysis.scala +++ b/src/compiler/scala/tools/nsc/transform/patmat/MatchAnalysis.scala @@ -213,9 +213,10 @@ trait TreeAndTypeAnalysis extends Debugging { // a type is "uncheckable" (for exhaustivity) if we don't statically know its subtypes (i.e., it's unsealed) // we consider tuple types with at least one component of a checkable type as a checkable type def uncheckableType(tp: Type): Boolean = { - val checkable = ( - (isTupleType(tp) && tupleComponents(tp).exists(tp => !uncheckableType(tp))) - || enumerateSubtypes(tp, grouped = false).nonEmpty) + val checkable = { + if (isTupleType(tp)) tupleComponents(tp).exists(tp => !uncheckableType(tp)) + else enumerateSubtypes(tp, grouped = false).nonEmpty + } // if (!checkable) debug.patmat("deemed uncheckable: "+ tp) !checkable } diff --git a/test/files/pos/t10373.flags b/test/files/pos/t10373.flags new file mode 100644 index 000000000000..85d8eb2ba295 --- /dev/null +++ b/test/files/pos/t10373.flags @@ -0,0 +1 @@ +-Xfatal-warnings diff --git a/test/files/pos/t10373.scala b/test/files/pos/t10373.scala new file mode 100644 index 000000000000..c588607d3d41 --- /dev/null +++ b/test/files/pos/t10373.scala @@ -0,0 +1,15 @@ +abstract class Foo { + def bar(): Unit = this match { + case Foo_1() => //do something + case Foo_2() => //do something + // Works fine + } + + def baz(that: Foo): Unit = (this, that) match { + case (Foo_1(), _) => //do something + case (Foo_2(), _) => //do something + // match may not be exhaustive + } +} +case class Foo_1() extends Foo +case class Foo_2() extends Foo