From 35d9bda62db6be7fa65e6e57c37296671e179e07 Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Tue, 3 Nov 2020 09:02:45 +0000 Subject: [PATCH] Switch off exhaustivity warnings for unsealed types (by default) Replaces `-Xno-unsealed-patmat-analysi` with `-Xlint:strict-unsealed-patmat`, switching the default behaviour to opt-in to this strictness. :( However, at least by being in the Xlint family, it's on if you opt-in to `-Xlint`. Reverts commit 0416c57a01a2b0feafc340893d64cd54ca7ae84c (w/ tweaks). --- project/ScalaOptionParser.scala | 4 +- .../tools/nsc/settings/ScalaSettings.scala | 3 +- .../scala/tools/nsc/settings/Warnings.scala | 2 + .../nsc/transform/patmat/MatchAnalysis.scala | 2 +- test/files/neg/patmat-seq-neg.check | 13 ------ test/files/neg/t11102.check | 21 ---------- test/files/neg/t11746.check | 6 +-- test/files/neg/t5365c.scala | 2 +- test/files/neg/t5898.check | 6 +-- test/files/neg/t7623.scala | 2 +- test/files/neg/t8597.scala | 2 +- test/files/neg/t8597b.scala | 2 +- test/files/neg/t8731.scala | 2 +- test/files/neg/tailrec-4.check | 10 ++--- test/files/neg/tailrec-4.scala | 1 - test/files/neg/unchecked-refinement.check | 6 +-- test/files/neg/unchecked3.scala | 2 +- .../files/neg/virtpatmat_unreach_select.check | 6 +-- test/files/{neg => pos}/t10680.scala | 0 test/files/run/matchonstream.check | 3 -- test/files/run/patmat-behavior.check | 42 ------------------- test/files/run/patmatnew.check | 39 ----------------- .../run/t6077_patmat_cse_irrefutable.scala | 1 - test/files/run/t6288.check | 3 -- test/files/run/t9644.check | 6 --- test/files/run/unapply.check | 3 -- test/files/run/unapplyArray.check | 3 -- test/files/run/uncheckedStable.check | 4 -- 28 files changed, 21 insertions(+), 175 deletions(-) rename test/files/{neg => pos}/t10680.scala (100%) diff --git a/project/ScalaOptionParser.scala b/project/ScalaOptionParser.scala index 9e7280fb22a0..ae5eff0d92cd 100644 --- a/project/ScalaOptionParser.scala +++ b/project/ScalaOptionParser.scala @@ -83,7 +83,7 @@ object ScalaOptionParser { // TODO retrieve these data programmatically, ala https://github.com/scala/scala-tool-support/blob/master/bash-completion/src/main/scala/BashCompletion.scala private def booleanSettingNames = List("-X", "-Xasync", "-Xcheckinit", "-Xdev", "-Xdisable-assertions", "-Xexperimental", "-Xfatal-warnings", "-Xlog-free-terms", "-Xlog-free-types", "-Xlog-implicit-conversions", "-Xlog-implicits", "-Xlog-reflective-calls", - "-Xno-forwarders", "-Xno-patmat-analysis", "-Xno-unsealed-patmat-analysis", "-Xnon-strict-patmat-analysis", "-Xprint-pos", "-Xprint-types", "-Xprompt", "-Xresident", "-Xshow-phases", "-Xverify", "-Y", + "-Xno-forwarders", "-Xno-patmat-analysis", "-Xnon-strict-patmat-analysis", "-Xprint-pos", "-Xprint-types", "-Xprompt", "-Xresident", "-Xshow-phases", "-Xverify", "-Y", "-Ybreak-cycles", "-Ydebug", "-Ycompact-trees", "-YdisableFlatCpCaching", "-Ydoc-debug", "-Yide-debug", "-Yissue-debug", "-Ylog-classpath", "-Ymacro-debug-lite", "-Ymacro-debug-verbose", "-Ymacro-no-expand", @@ -108,7 +108,7 @@ object ScalaOptionParser { "-g" -> List("line", "none", "notailcails", "source", "vars"), "-target" -> targetSettingNames) private def multiChoiceSettingNames = Map[String, List[String]]( - "-Xlint" -> List("adapted-args", "nullary-unit", "inaccessible", "nullary-override", "infer-any", "missing-interpolator", "doc-detached", "private-shadow", "type-parameter-shadow", "poly-implicit-overload", "option-implicit", "delayedinit-select", "package-object-classes", "stars-align", "constant", "unused", "eta-zero"), + "-Xlint" -> List("adapted-args", "nullary-unit", "inaccessible", "nullary-override", "infer-any", "missing-interpolator", "doc-detached", "private-shadow", "type-parameter-shadow", "poly-implicit-overload", "option-implicit", "delayedinit-select", "package-object-classes", "stars-align", "strict-unsealed-patmat", "constant", "unused", "eta-zero"), "-language" -> List("help", "_", "dynamics", "postfixOps", "reflectiveCalls", "implicitConversions", "higherKinds", "existentials", "experimental.macros"), "-opt" -> List("unreachable-code", "simplify-jumps", "compact-locals", "copy-propagation", "redundant-casts", "box-unbox", "nullness-tracking", "closure-invocations" , "allow-skip-core-module-init", "assume-modules-non-null", "allow-skip-class-loading", "inline", "l:none", "l:default", "l:method", "l:inline", "l:project", "l:classpath"), "-Ywarn-unused" -> List("imports", "patvars", "privates", "locals", "explicits", "implicits", "params"), diff --git a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala index f70f4aecaf1e..d070a7870652 100644 --- a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala +++ b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala @@ -168,8 +168,7 @@ trait ScalaSettings extends StandardScalaSettings with Warnings { _: MutableSett def isAtLeastJunit = isTruthy || XmixinForceForwarders.value == "junit" } - val nonStrictPatmatAnalysis = BooleanSetting("-Xnon-strict-patmat-analysis", "Disable strict exhaustivity analysis, which assumes guards are false and refutable extractors don't match") - val noUnsealedPatmatAnalysis = BooleanSetting("-Xno-unsealed-patmat-analysis", "Pattern match on an unsealed class without a catch-all.") + val nonStrictPatmatAnalysis = BooleanSetting("-Xnon-strict-patmat-analysis", "Disable strict exhaustivity analysis, which assumes guards are false and refutable extractors don't match") // XML parsing options object XxmlSettings extends MultiChoiceEnumeration { diff --git a/src/compiler/scala/tools/nsc/settings/Warnings.scala b/src/compiler/scala/tools/nsc/settings/Warnings.scala index 4a6c330cd865..2703f4a0ea39 100644 --- a/src/compiler/scala/tools/nsc/settings/Warnings.scala +++ b/src/compiler/scala/tools/nsc/settings/Warnings.scala @@ -177,6 +177,7 @@ trait Warnings { val DelayedInitSelect = LintWarning("delayedinit-select", "Selecting member of DelayedInit.") val PackageObjectClasses = LintWarning("package-object-classes", "Class or object defined in package object.") val StarsAlign = LintWarning("stars-align", "In a pattern, a sequence wildcard `_*` should match all of a repeated parameter.") + val StrictUnsealedPatMat = LintWarning("strict-unsealed-patmat", "Pattern match on an unsealed class without a catch-all.") val Constant = LintWarning("constant", "Evaluation of a constant arithmetic expression resulted in an error.") val Unused = LintWarning("unused", "Enable -Wunused:imports,privates,locals,implicits,nowarn.") val NonlocalReturn = LintWarning("nonlocal-return", "A return statement used an exception for flow control.") @@ -208,6 +209,7 @@ trait Warnings { def warnOptionImplicit = lint contains OptionImplicit def warnDelayedInit = lint contains DelayedInitSelect def warnPackageObjectClasses = lint contains PackageObjectClasses + def warnStrictUnsealedPatMat = lint contains StrictUnsealedPatMat def warnStarsAlign = lint contains StarsAlign def warnConstant = lint contains Constant def lintUnused = lint contains Unused diff --git a/src/compiler/scala/tools/nsc/transform/patmat/MatchAnalysis.scala b/src/compiler/scala/tools/nsc/transform/patmat/MatchAnalysis.scala index 916b14646412..63ac5f9be80d 100644 --- a/src/compiler/scala/tools/nsc/transform/patmat/MatchAnalysis.scala +++ b/src/compiler/scala/tools/nsc/transform/patmat/MatchAnalysis.scala @@ -514,7 +514,7 @@ trait MatchAnalysis extends MatchApproximation { // exhaustivity - def exhaustive(prevBinder: Symbol, cases: List[List[TreeMaker]], pt: Type): List[String] = if (settings.noUnsealedPatmatAnalysis && uncheckableType(prevBinder.info)) Nil else { + def exhaustive(prevBinder: Symbol, cases: List[List[TreeMaker]], pt: Type): List[String] = if (!settings.warnStrictUnsealedPatMat && uncheckableType(prevBinder.info)) Nil else { // customize TreeMakersToProps (which turns a tree of tree makers into a more abstract DAG of tests) // - approximate the pattern `List()` (unapplySeq on List with empty length) as `Nil`, // otherwise the common (xs: List[Any]) match { case List() => case x :: xs => } is deemed unexhaustive diff --git a/test/files/neg/patmat-seq-neg.check b/test/files/neg/patmat-seq-neg.check index a1eb5d963021..2297f1efbb3e 100644 --- a/test/files/neg/patmat-seq-neg.check +++ b/test/files/neg/patmat-seq-neg.check @@ -1,9 +1,3 @@ -patmat-seq-neg.scala:12: warning: match may not be exhaustive. - def t2: Any = 2 match { - ^ -patmat-seq-neg.scala:15: warning: match may not be exhaustive. - def t3: Any = 2 match { - ^ patmat-seq-neg.scala:15: error: error during expansion of this match (this is a scalac bug). The underlying error was: type mismatch; found : scala.collection.mutable.ArrayBuffer[Int] @@ -14,15 +8,8 @@ patmat-seq-neg.scala:18: error: error during expansion of this match (this is a The underlying error was: value toSeq is not a member of Array[Int] def t4: Any = 2 match { ^ -patmat-seq-neg.scala:21: warning: match may not be exhaustive. - def t5: Any = 2 match { - ^ -patmat-seq-neg.scala:24: warning: match may not be exhaustive. - def t6: Any = 2 match { - ^ patmat-seq-neg.scala:24: error: error during expansion of this match (this is a scalac bug). The underlying error was: value drop is not a member of Array[Int] def t6: Any = 2 match { ^ -4 warnings 3 errors diff --git a/test/files/neg/t11102.check b/test/files/neg/t11102.check index c96a6db48f2d..b23c79e154ea 100644 --- a/test/files/neg/t11102.check +++ b/test/files/neg/t11102.check @@ -1,34 +1,13 @@ -t11102.scala:2: warning: match may not be exhaustive. -It would fail on the following input: (x: ImmutableSeq forSome x not in ImmutableCons) - def f(x: ImmutableSeq) = x match { - ^ -t11102.scala:5: warning: match may not be exhaustive. -It would fail on the following input: (x: MutableSeq forSome x not in MutableCons) - def f(x: MutableSeq) = x match { - ^ t11102.scala:5: error: error during expansion of this match (this is a scalac bug). The underlying error was: type mismatch; found : Seq[MutableCons] (in scala.collection.mutable) required: Seq[MutableCons] (in scala.collection.immutable) def f(x: MutableSeq) = x match { ^ -t11102.scala:8: warning: match may not be exhaustive. -It would fail on the following input: (x: CollectionSeq forSome x not in CollectionCons) - def f(x: CollectionSeq) = x match { - ^ t11102.scala:8: error: error during expansion of this match (this is a scalac bug). The underlying error was: type mismatch; found : Seq[CollectionCons] (in scala.collection) required: Seq[CollectionCons] (in scala.collection.immutable) def f(x: CollectionSeq) = x match { ^ -t11102.scala:11: warning: match may not be exhaustive. -It would fail on the following input: (x: ScalaSeq forSome x not in ScalaCons) - def f(x: ScalaSeq) = x match { - ^ -t11102.scala:14: warning: match may not be exhaustive. -It would fail on the following input: (x: DefaultSeq forSome x not in DefaultCons) - def f(x: DefaultSeq) = x match { - ^ -5 warnings 2 errors diff --git a/test/files/neg/t11746.check b/test/files/neg/t11746.check index 040c41563b7d..a7334117cd21 100644 --- a/test/files/neg/t11746.check +++ b/test/files/neg/t11746.check @@ -1,11 +1,7 @@ -t11746.scala:16: warning: match may not be exhaustive. -It would fail on the following input: (x: Try forSome x not in Failure) - private def get(a: String): Unit = Try(a) match { - ^ t11746.scala:18: warning: failed to determine if e should be inlined: The method e()Ljava/lang/Throwable; could not be found in the class java/lang/Object or any of its parents. case Failure(e) => println(e.toString) ^ error: No warnings can be incurred under -Werror. -2 warnings +1 warning 1 error diff --git a/test/files/neg/t5365c.scala b/test/files/neg/t5365c.scala index f407296dcacf..d79cd905c0d4 100644 --- a/test/files/neg/t5365c.scala +++ b/test/files/neg/t5365c.scala @@ -1,4 +1,4 @@ -// scalac: -Xfatal-warnings +// scalac: -Xfatal-warnings -Xlint:strict-unsealed-patmat object C { trait Z final case class Q(i: Int) extends Z diff --git a/test/files/neg/t5898.check b/test/files/neg/t5898.check index 6dc1a13d5a7a..9c9e7f201995 100644 --- a/test/files/neg/t5898.check +++ b/test/files/neg/t5898.check @@ -6,10 +6,6 @@ t5898.scala:10: warning: match may not be exhaustive. It would fail on the following input: C(_) val D(x) = t ^ -t5898.scala:11: warning: match may not be exhaustive. -It would fail on the following input: (x: Any forSome x not in D) - val D(y) = (null: Any) - ^ error: No warnings can be incurred under -Werror. -3 warnings +2 warnings 1 error diff --git a/test/files/neg/t7623.scala b/test/files/neg/t7623.scala index 8eac860ea49b..fb36d0b5d737 100644 --- a/test/files/neg/t7623.scala +++ b/test/files/neg/t7623.scala @@ -1,4 +1,4 @@ -// scalac: -Xlint:stars-align -Xfatal-warnings -Xno-unsealed-patmat-analysis +// scalac: -Xlint:stars-align -Xfatal-warnings // diff --git a/test/files/neg/t8597.scala b/test/files/neg/t8597.scala index 6d54ffe45d7d..b5925c48a1ca 100644 --- a/test/files/neg/t8597.scala +++ b/test/files/neg/t8597.scala @@ -1,4 +1,4 @@ -// scalac: -Xfatal-warnings -Xno-unsealed-patmat-analysis +// scalac: -Xfatal-warnings // class Unchecked[C] { def nowarn[T] = (null: Any) match { case _: Some[T] => } // warn (did not warn due to scala/bug#8597) diff --git a/test/files/neg/t8597b.scala b/test/files/neg/t8597b.scala index 07bc43ee44fa..26b3f97c1500 100644 --- a/test/files/neg/t8597b.scala +++ b/test/files/neg/t8597b.scala @@ -1,4 +1,4 @@ -// scalac: -Xfatal-warnings -Xno-unsealed-patmat-analysis +// scalac: -Xfatal-warnings // object Unchecked { (null: Any) match { diff --git a/test/files/neg/t8731.scala b/test/files/neg/t8731.scala index 903a5108bec7..fd85fbe42ae6 100644 --- a/test/files/neg/t8731.scala +++ b/test/files/neg/t8731.scala @@ -1,4 +1,4 @@ -// scalac: -Xfatal-warnings -Xno-unsealed-patmat-analysis +// scalac: -Xfatal-warnings // class C { // not a compile-time constant due to return type diff --git a/test/files/neg/tailrec-4.check b/test/files/neg/tailrec-4.check index 4f0a182154ec..0b2df62c6c80 100644 --- a/test/files/neg/tailrec-4.check +++ b/test/files/neg/tailrec-4.check @@ -1,16 +1,16 @@ -tailrec-4.scala:7: error: could not optimize @tailrec annotated method foo: it contains a recursive call not in tail position +tailrec-4.scala:6: error: could not optimize @tailrec annotated method foo: it contains a recursive call not in tail position @tailrec def foo: Int = foo + 1 ^ -tailrec-4.scala:12: error: could not optimize @tailrec annotated method foo: it contains a recursive call not in tail position +tailrec-4.scala:11: error: could not optimize @tailrec annotated method foo: it contains a recursive call not in tail position @tailrec def foo: Int = foo + 1 ^ -tailrec-4.scala:18: error: could not optimize @tailrec annotated method foo: it contains a recursive call not in tail position +tailrec-4.scala:17: error: could not optimize @tailrec annotated method foo: it contains a recursive call not in tail position @tailrec def foo: Int = foo + 1 ^ -tailrec-4.scala:24: error: could not optimize @tailrec annotated method foo: it contains a recursive call not in tail position +tailrec-4.scala:23: error: could not optimize @tailrec annotated method foo: it contains a recursive call not in tail position @tailrec def foo: Int = foo + 1 ^ -tailrec-4.scala:32: error: could not optimize @tailrec annotated method foo: it contains a recursive call not in tail position +tailrec-4.scala:31: error: could not optimize @tailrec annotated method foo: it contains a recursive call not in tail position @tailrec def foo: Int = foo + 1 ^ 5 errors diff --git a/test/files/neg/tailrec-4.scala b/test/files/neg/tailrec-4.scala index a1fc8b5f78c1..90dad3c86542 100644 --- a/test/files/neg/tailrec-4.scala +++ b/test/files/neg/tailrec-4.scala @@ -1,4 +1,3 @@ -// scalac: -Xno-unsealed-patmat-analysis import annotation._ object Tail { diff --git a/test/files/neg/unchecked-refinement.check b/test/files/neg/unchecked-refinement.check index b24a7d27c3ba..95dcec0c89ea 100644 --- a/test/files/neg/unchecked-refinement.check +++ b/test/files/neg/unchecked-refinement.check @@ -10,15 +10,11 @@ unchecked-refinement.scala:25: warning: a pattern match on a refinement type is unchecked-refinement.scala:26: warning: a pattern match on a refinement type is unchecked /* nowarn - todo */ case x: AnyRef { def size: Int } if b => x.size // this could/should do a static conformance test and not warn ^ -unchecked-refinement.scala:18: warning: match may not be exhaustive. -It would fail on the following input: ?? - def f3[T, U, V](x: Foo[T, U, V]) = x match { - ^ unchecked-refinement.scala:24: warning: match may not be exhaustive. It would fail on the following inputs: List(_), Nil def f4(xs: List[Int]) = xs match { ^ warning: 1 feature warning; re-run with -feature for details error: No warnings can be incurred under -Werror. -7 warnings +6 warnings 1 error diff --git a/test/files/neg/unchecked3.scala b/test/files/neg/unchecked3.scala index abb73b5efca2..c8b636233957 100644 --- a/test/files/neg/unchecked3.scala +++ b/test/files/neg/unchecked3.scala @@ -1,4 +1,4 @@ -// scalac: -Xfatal-warnings -Xno-unsealed-patmat-analysis +// scalac: -Xfatal-warnings // sealed trait A2[T1] final class B2[T1, T2] extends A2[T1] diff --git a/test/files/neg/virtpatmat_unreach_select.check b/test/files/neg/virtpatmat_unreach_select.check index 24dfbf3245ea..7b24eda8df24 100644 --- a/test/files/neg/virtpatmat_unreach_select.check +++ b/test/files/neg/virtpatmat_unreach_select.check @@ -1,10 +1,6 @@ virtpatmat_unreach_select.scala:12: warning: unreachable code case WARNING.id => // unreachable ^ -virtpatmat_unreach_select.scala:9: warning: match may not be exhaustive. -It would fail on the following input: (x: Int forSome x not in (id, id)) - (0: Int) match { - ^ error: No warnings can be incurred under -Werror. -2 warnings +1 warning 1 error diff --git a/test/files/neg/t10680.scala b/test/files/pos/t10680.scala similarity index 100% rename from test/files/neg/t10680.scala rename to test/files/pos/t10680.scala diff --git a/test/files/run/matchonstream.check b/test/files/run/matchonstream.check index 6e42636ea287..7a44e93b2628 100644 --- a/test/files/run/matchonstream.check +++ b/test/files/run/matchonstream.check @@ -1,4 +1 @@ -matchonstream.scala:2: warning: match may not be exhaustive. - LazyList.from(1) match { case LazyList(1, 2, x @_*) => println(s"It worked! (class: ${x.getClass.getSimpleName})") } - ^ It worked! (class: LazyList) diff --git a/test/files/run/patmat-behavior.check b/test/files/run/patmat-behavior.check index 01e662ac11dc..7cc213078324 100644 --- a/test/files/run/patmat-behavior.check +++ b/test/files/run/patmat-behavior.check @@ -88,30 +88,6 @@ patmat-behavior.scala:87: warning: fruitless type test: a value of type s.C21[A] patmat-behavior.scala:87: warning: fruitless type test: a value of type s.C21[A] cannot also be a s.C11[A] def gd6[A](x: C21[A]) = x match { case G00() => ??? ; case G10(x) => x ; case G20(x, y) => x ; case G01(xs @ _*) => xs.head ; case G11(x, ys @ _*) => x ; case G21(x, y, zs @ _*) => x } ^ -patmat-behavior.scala:36: warning: match may not be exhaustive. -It would fail on the following inputs: (x: Any forSome x not in (s.C00[?], s.C01[?], s.C10[?], s.C11[?], s.C20[?], s.C21[?])), ??, C01(_), C11(_, _), C21(_, _, _) - def ga1(x: Any) = x match { case C00() => 1 ; case C10(x) => 2 ; case C20(x, y) => 3 ; case C01(xs) => 4 ; case C11(x, ys) => 5 ; case C21(x, y, zs) => 6 } - ^ -patmat-behavior.scala:37: warning: match may not be exhaustive. -It would fail on the following inputs: (x: Any forSome x not in (s.C00[?], s.C01[?], s.C10[?], s.C11[?], s.C20[?], s.C21[?])), ??, C01(_), C11(_, _), C21(_, _, _) - def ga2(x: Any) = x match { case C00() => 1 ; case C10(x) => 2 ; case C20(x, y) => 3 ; case C01(xs) => 4 ; case C11(x, ys) => 5 ; case C21(x, y, zs) => 6 } - ^ -patmat-behavior.scala:38: warning: match may not be exhaustive. -It would fail on the following inputs: (x: Any forSome x not in (s.C00[?], s.C01[?], s.C10[?], s.C11[?], s.C20[?], s.C21[?])), ??, C01(_), C11(_, _), C21(_, _, _) - def ga3(x: Any) = x match { case C00() => 1 ; case C10(x) => 2 ; case C20(x, y) => 3 ; case C01(xs) => 4 ; case C11(x, ys) => 5 ; case C21(x, y, zs) => 6 } - ^ -patmat-behavior.scala:39: warning: match may not be exhaustive. -It would fail on the following inputs: (x: Any forSome x not in (s.C00[?], s.C01[?], s.C10[?], s.C11[?], s.C20[?], s.C21[?])), ??, C01(_), C11(_, _), C21(_, _, _) - def ga4(x: Any) = x match { case C00() => 1 ; case C10(x) => 2 ; case C20(x, y) => 3 ; case C01(xs) => 4 ; case C11(x, ys) => 5 ; case C21(x, y, zs) => 6 } - ^ -patmat-behavior.scala:40: warning: match may not be exhaustive. -It would fail on the following inputs: (x: Any forSome x not in (s.C00[?], s.C01[?], s.C10[?], s.C11[?], s.C20[?], s.C21[?])), ??, C01(_), C11(_, _), C21(_, _, _) - def ga5(x: Any) = x match { case C00() => 1 ; case C10(x) => 2 ; case C20(x, y) => 3 ; case C01(xs) => 4 ; case C11(x, ys) => 5 ; case C21(x, y, zs) => 6 } - ^ -patmat-behavior.scala:41: warning: match may not be exhaustive. -It would fail on the following inputs: (x: Any forSome x not in (s.C00[?], s.C01[?], s.C10[?], s.C11[?], s.C20[?], s.C21[?])), ??, C01(_), C11(_, _), C21(_, _, _) - def ga6(x: Any) = x match { case C00() => 1 ; case C10(x) => 2 ; case C20(x, y) => 3 ; case C01(xs) => 4 ; case C11(x, ys) => 5 ; case C21(x, y, zs) => 6 } - ^ patmat-behavior.scala:43: warning: match may not be exhaustive. It would fail on the following inputs: C00(), C01(_), C10(_), C11(_, _), C20(_, _), C21(_, _, _) def gb1[A](x: C[A]) = x match { case E00() => ??? ; case E10(x) => x ; case E20(x, y) => x ; case E01(xs @ _*) => xs.head ; case E11(x, ys @ _*) => x ; case E21(x, y, zs @ _*) => x } @@ -160,24 +136,6 @@ patmat-behavior.scala:55: warning: match may not be exhaustive. It would fail on the following inputs: C00(), C01(_), C10(_), C11(_, _), C20(_, _), C21(_, _, _) def gc6[A](x: C[A]) = x match { case F00() => ??? ; case F10(x) => x ; case F20(x, y) => x ; case F01(xs @ _*) => xs.head ; case F11(x, ys @ _*) => x ; case F21(x, y, zs @ _*) => x } ^ -patmat-behavior.scala:57: warning: match may not be exhaustive. - def gd1[A, B <: C[A]](x: B) = x match { case F00() => ??? ; case F10(x) => x ; case F20(x, y) => x ; case F01(xs @ _*) => xs.head ; case F11(x, ys @ _*) => x ; case F21(x, y, zs @ _*) => x } - ^ -patmat-behavior.scala:58: warning: match may not be exhaustive. - def gd2[A, B <: C[A]](x: B) = x match { case F00() => ??? ; case F10(x) => x ; case F20(x, y) => x ; case F01(xs @ _*) => xs.head ; case F11(x, ys @ _*) => x ; case F21(x, y, zs @ _*) => x } - ^ -patmat-behavior.scala:59: warning: match may not be exhaustive. - def gd3[A, B <: C[A]](x: B) = x match { case F00() => ??? ; case F10(x) => x ; case F20(x, y) => x ; case F01(xs @ _*) => xs.head ; case F11(x, ys @ _*) => x ; case F21(x, y, zs @ _*) => x } - ^ -patmat-behavior.scala:60: warning: match may not be exhaustive. - def gd4[A, B <: C[A]](x: B) = x match { case F00() => ??? ; case F10(x) => x ; case F20(x, y) => x ; case F01(xs @ _*) => xs.head ; case F11(x, ys @ _*) => x ; case F21(x, y, zs @ _*) => x } - ^ -patmat-behavior.scala:61: warning: match may not be exhaustive. - def gd5[A, B <: C[A]](x: B) = x match { case F00() => ??? ; case F10(x) => x ; case F20(x, y) => x ; case F01(xs @ _*) => xs.head ; case F11(x, ys @ _*) => x ; case F21(x, y, zs @ _*) => x } - ^ -patmat-behavior.scala:62: warning: match may not be exhaustive. - def gd6[A, B <: C[A]](x: B) = x match { case F00() => ??? ; case F10(x) => x ; case F20(x, y) => x ; case F01(xs @ _*) => xs.head ; case F11(x, ys @ _*) => x ; case F21(x, y, zs @ _*) => x } - ^ patmat-behavior.scala:68: warning: match may not be exhaustive. It would fail on the following input: C00() def gb1[A](x: C00[A]) = x match { case E00() => ??? ; case E10(x) => x ; case E20(x, y) => x ; case E01(xs @ _*) => xs.head ; case E11(x, ys @ _*) => x ; case E21(x, y, zs @ _*) => x } diff --git a/test/files/run/patmatnew.check b/test/files/run/patmatnew.check index da5143a3f1f2..e27759138347 100644 --- a/test/files/run/patmatnew.check +++ b/test/files/run/patmatnew.check @@ -16,22 +16,6 @@ patmatnew.scala:356: warning: multiline expressions might require enclosing pare patmatnew.scala:356: warning: a pure expression does nothing in statement position case 3 => assert(false); "KO" ^ -patmatnew.scala:119: warning: match may not be exhaustive. -It would fail on the following inputs: (x: Any forSome x not in Test.Test717.foo1.Bar), Bar((x: Int forSome x not in 2)) - val res = (foo1.Bar(2): Any) match { - ^ -patmatnew.scala:138: warning: match may not be exhaustive. -It would fail on the following inputs: (x: Shmeez.this.Tree forSome x not in (HagbardCeline, Shmeez.this.Beez)), Beez((x: Int forSome x not in 2)) - def foo = tree match { - ^ -patmatnew.scala:148: warning: match may not be exhaustive. -It would fail on the following inputs: (x: Test.TestGuards.Tree forSome x not in Test.TestGuards.Beez), Beez(_) - val res = tree match { - ^ -patmatnew.scala:153: warning: match may not be exhaustive. -It would fail on the following inputs: (x: Test.TestGuards.Tree forSome x not in Test.TestGuards.Beez), Beez(_) - val ret = (Beez(3): Tree) match { - ^ patmatnew.scala:175: warning: match may not be exhaustive. It would fail on the following inputs: List(_), Nil def doMatch(xs: List[String]): String = xs match { @@ -40,13 +24,6 @@ patmatnew.scala:178: warning: match may not be exhaustive. It would fail on the following inputs: List(_), Nil def doMatch2(xs: List[String]): List[String] = xs match { ^ -patmatnew.scala:193: warning: match may not be exhaustive. - def doMatch(l: Seq[String]): String = l match { - ^ -patmatnew.scala:264: warning: match may not be exhaustive. -It would fail on the following inputs: (x: Any forSome x not in Test.TestSequence06.A), A((x: Any forSome x not in (1, Test.TestSequence06.A))), A(A((x: Any forSome x not in 1))) - def doMatch(x: Any, bla: Int) = x match { - ^ patmatnew.scala:280: warning: match may not be exhaustive. It would fail on the following inputs: List(_), Nil def doMatch1(xs: List[Char]) = xs match { @@ -55,22 +32,6 @@ patmatnew.scala:283: warning: match may not be exhaustive. It would fail on the following inputs: List(_), Nil def doMatch2(xs: List[Char]) = xs match { ^ -patmatnew.scala:286: warning: match may not be exhaustive. - def doMatch3(xs: Seq[Char]) = xs match { - ^ -patmatnew.scala:290: warning: match may not be exhaustive. - def doMatch4(xs: Seq[Char]) = xs match { - ^ -patmatnew.scala:318: warning: match may not be exhaustive. - lazyList match { - ^ -patmatnew.scala:396: warning: match may not be exhaustive. - "baz" match { - ^ -patmatnew.scala:443: warning: match may not be exhaustive. -It would fail on the following input: (x: 42 forSome x not in FooBar) - def lala() = 42 match { - ^ patmatnew.scala:492: warning: unreachable code case _ if false => ^ diff --git a/test/files/run/t6077_patmat_cse_irrefutable.scala b/test/files/run/t6077_patmat_cse_irrefutable.scala index cbbe999970ff..18db6c13ef20 100644 --- a/test/files/run/t6077_patmat_cse_irrefutable.scala +++ b/test/files/run/t6077_patmat_cse_irrefutable.scala @@ -1,4 +1,3 @@ -// scalac: -Xno-unsealed-patmat-analysis class LiteralNode(val value: Any) object LiteralNode { diff --git a/test/files/run/t6288.check b/test/files/run/t6288.check index eb431f85e1e2..eb1ef1105679 100644 --- a/test/files/run/t6288.check +++ b/test/files/run/t6288.check @@ -1,6 +1,3 @@ -newSource1.scala:28: warning: match may not be exhaustive. - 0 match { - ^ [[syntax trees at end of patmat]] // newSource1.scala [0:553]package [0:0] { [0:151]object Case3 extends [13:151][152]scala.AnyRef { diff --git a/test/files/run/t9644.check b/test/files/run/t9644.check index 3ea160b69d08..e69de29bb2d1 100644 --- a/test/files/run/t9644.check +++ b/test/files/run/t9644.check @@ -1,6 +0,0 @@ -t9644.scala:14: warning: match may not be exhaustive. - d.tree match { - ^ -t9644.scala:20: warning: match may not be exhaustive. - r.tree match { - ^ diff --git a/test/files/run/unapply.check b/test/files/run/unapply.check index 84ab1daf5fd7..5ba34b58e8b4 100644 --- a/test/files/run/unapply.check +++ b/test/files/run/unapply.check @@ -1,6 +1,3 @@ unapply.scala:62: warning: comparing values of types Null and Null using `==` will always yield true assert(doMatch2(b) == null) ^ -unapply.scala:104: warning: match may not be exhaustive. - lazyList match { - ^ diff --git a/test/files/run/unapplyArray.check b/test/files/run/unapplyArray.check index 6400dc893728..e69de29bb2d1 100644 --- a/test/files/run/unapplyArray.check +++ b/test/files/run/unapplyArray.check @@ -1,3 +0,0 @@ -unapplyArray.scala:26: warning: match may not be exhaustive. - val zl = zs match { - ^ diff --git a/test/files/run/uncheckedStable.check b/test/files/run/uncheckedStable.check index 1a7b952a9104..e69de29bb2d1 100644 --- a/test/files/run/uncheckedStable.check +++ b/test/files/run/uncheckedStable.check @@ -1,4 +0,0 @@ -uncheckedStable.scala:9: warning: match may not be exhaustive. -It would fail on the following input: (x: Any forSome x not in (Test.this.A, Test.this.T, Test.this.o)) - def m(a: Any) = a match { - ^