Skip to content

Commit 0416c57

Browse files
committed
Reverse -Xlint:strict-unsealed-patmat into -Xno-unsealed-patmat-analysis
1 parent cb391c2 commit 0416c57

File tree

139 files changed

+420
-163
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

139 files changed

+420
-163
lines changed

project/ScalaOptionParser.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ object ScalaOptionParser {
8383

8484
// TODO retrieve these data programmatically, ala https://github.com/scala/scala-tool-support/blob/master/bash-completion/src/main/scala/BashCompletion.scala
8585
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",
86-
"-Xno-forwarders", "-Xno-patmat-analysis", "-Xprint-pos", "-Xprint-types", "-Xprompt", "-Xresident", "-Xshow-phases", "-Xverify", "-Y",
86+
"-Xno-forwarders", "-Xno-patmat-analysis", "-Xno-unsealed-patmat-analysis", "-Xprint-pos", "-Xprint-types", "-Xprompt", "-Xresident", "-Xshow-phases", "-Xverify", "-Y",
8787
"-Ybreak-cycles", "-Ydebug", "-Ycompact-trees", "-YdisableFlatCpCaching", "-Ydoc-debug",
8888
"-Yide-debug",
8989
"-Yissue-debug", "-Ylog-classpath", "-Ymacro-debug-lite", "-Ymacro-debug-verbose", "-Ymacro-no-expand",
@@ -108,7 +108,7 @@ object ScalaOptionParser {
108108
"-g" -> List("line", "none", "notailcails", "source", "vars"),
109109
"-target" -> targetSettingNames)
110110
private def multiChoiceSettingNames = Map[String, List[String]](
111-
"-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"),
111+
"-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"),
112112
"-language" -> List("help", "_", "dynamics", "postfixOps", "reflectiveCalls", "implicitConversions", "higherKinds", "existentials", "experimental.macros"),
113113
"-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"),
114114
"-Ywarn-unused" -> List("imports", "patvars", "privates", "locals", "explicits", "implicits", "params"),

src/compiler/scala/tools/nsc/settings/ScalaSettings.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ trait ScalaSettings extends StandardScalaSettings with Warnings { _: MutableSett
168168
def isAtLeastJunit = isTruthy || XmixinForceForwarders.value == "junit"
169169
}
170170

171+
val noUnsealedPatmatAnalysis = BooleanSetting("-Xno-unsealed-patmat-analysis", "Pattern match on an unsealed class without a catch-all.")
172+
171173
// XML parsing options
172174
object XxmlSettings extends MultiChoiceEnumeration {
173175
val coalescing = Choice("coalescing", "Convert PCData to Text and coalesce sibling nodes")

src/compiler/scala/tools/nsc/settings/Warnings.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ trait Warnings {
176176
val DelayedInitSelect = LintWarning("delayedinit-select", "Selecting member of DelayedInit.")
177177
val PackageObjectClasses = LintWarning("package-object-classes", "Class or object defined in package object.")
178178
val StarsAlign = LintWarning("stars-align", "In a pattern, a sequence wildcard `_*` should match all of a repeated parameter.")
179-
val StrictUnsealedPatMat = LintWarning("strict-unsealed-patmat", "Pattern match on an unsealed class without a catch-all.")
180179
val Constant = LintWarning("constant", "Evaluation of a constant arithmetic expression resulted in an error.")
181180
val Unused = LintWarning("unused", "Enable -Wunused:imports,privates,locals,implicits,nowarn.")
182181
val NonlocalReturn = LintWarning("nonlocal-return", "A return statement used an exception for flow control.")
@@ -208,7 +207,6 @@ trait Warnings {
208207
def warnOptionImplicit = lint contains OptionImplicit
209208
def warnDelayedInit = lint contains DelayedInitSelect
210209
def warnPackageObjectClasses = lint contains PackageObjectClasses
211-
def warnStrictUnsealedPatMat = lint contains StrictUnsealedPatMat
212210
def warnStarsAlign = lint contains StarsAlign
213211
def warnConstant = lint contains Constant
214212
def lintUnused = lint contains Unused

src/compiler/scala/tools/nsc/transform/patmat/MatchAnalysis.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ trait MatchAnalysis extends MatchApproximation {
498498

499499
// exhaustivity
500500

501-
def exhaustive(prevBinder: Symbol, cases: List[List[TreeMaker]], pt: Type): List[String] = if (!settings.warnStrictUnsealedPatMat && uncheckableType(prevBinder.info)) Nil else {
501+
def exhaustive(prevBinder: Symbol, cases: List[List[TreeMaker]], pt: Type): List[String] = if (settings.noUnsealedPatmatAnalysis && uncheckableType(prevBinder.info)) Nil else {
502502
// customize TreeMakersToProps (which turns a tree of tree makers into a more abstract DAG of tests)
503503
// - approximate the pattern `List()` (unapplySeq on List with empty length) as `Nil`,
504504
// otherwise the common (xs: List[Any]) match { case List() => case x :: xs => } is deemed unexhaustive

test/async/jvm/anf.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,7 @@ package scala.async.run.anf {
387387
await(fut(1)) match {
388388
case Up => 1.0
389389
case Down => -1.0
390+
case x => throw new MatchError(x)
390391
}
391392
}
392393
sign.block mustBe 1.0

test/async/jvm/concurrent_GenericTypeBoundaryIssue.check

Whitespace-only changes.

test/async/jvm/concurrent_NegativeArraySizeException.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ object Test extends App { test()
99
def foo(foo: Any, bar: Any) = ()
1010
def getValue = async {4.2}
1111
def func(f: Any) = async {
12-
foo(f match { case _ if "".isEmpty => 2 }, await(getValue));
12+
foo(f match { case _ if "".isEmpty => 2 case x => throw new MatchError(x) }, await(getValue));
1313
}
1414

1515
def test() = Await.result(func(4), Duration.Inf)

test/async/jvm/concurrent_shadowing.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ object Test extends App { test
2020
case _ => foo; ()
2121
}
2222
()
23+
case x => throw new MatchError(x)
2324
}
2425
()
2526
}, Duration.Inf)

test/async/jvm/futures.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ package scala.async.run.futures {
8585
case "Hello" => Future { "World" }
8686
case "Failure" => Future.failed(new RuntimeException("Expected exception; to test fault-tolerance"))
8787
case "NoReply" => Promise[String]().future
88+
case x => throw new MatchError(x)
8889
}
8990

9091
val defaultTimeout = 5 seconds

test/async/jvm/match0.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ package scala.async.run.match0 {
119119
await(0)
120120
case buf: Double =>
121121
await(2)
122+
case x => throw new MatchError(x)
122123
}
123124
})
124125

0 commit comments

Comments
 (0)