From ec5b54f4fd0f3874de32f077e8fa29e6f629e66d Mon Sep 17 00:00:00 2001 From: Som Snytt Date: Fri, 8 Mar 2024 10:14:19 -0800 Subject: [PATCH 1/2] -Wconf:x,y is -Wconf:x -Wconf:y --- src/compiler/scala/tools/nsc/settings/MutableSettings.scala | 6 +++--- test/junit/scala/tools/nsc/reporters/WConfTest.scala | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/compiler/scala/tools/nsc/settings/MutableSettings.scala b/src/compiler/scala/tools/nsc/settings/MutableSettings.scala index f43acc62c21b..342bb4b95636 100644 --- a/src/compiler/scala/tools/nsc/settings/MutableSettings.scala +++ b/src/compiler/scala/tools/nsc/settings/MutableSettings.scala @@ -700,7 +700,7 @@ class MutableSettings(val errorFn: String => Unit, val pathFactory: PathFactory) } def tryToSet(args: List[String]) = tryToSetArgs(args, halting = true) - def tryToSetColon(args: List[String]) = tryToSetArgs(args, halting = false) + def tryToSetColon(args: List[String]) = tryToSetArgs(args, halting = false) override def tryToSetFromPropertyValue(s: String) = tryToSet(s.trim.split(',').toList) // used from ide /** Try to set args, handling "help" and default. @@ -822,12 +822,12 @@ class MutableSettings(val errorFn: String => Unit, val pathFactory: PathFactory) case Nil => (seen, Nil) } val (seen, rest) = loop(Nil, args) - if (prepend) value = value.prependedAll(seen.reverse) + if (prepend) value = value.prependedAll(seen) else value = value.appendedAll(seen.reverse) Some(rest) } def tryToSet(args: List[String]) = tryToSetArgs(args, halting = true) - def tryToSetColon(args: List[String]) = tryToSetArgs(args, halting = false) + def tryToSetColon(args: List[String]) = tryToSetArgs(args, halting = false) override def tryToSetFromPropertyValue(s: String) = tryToSet(s.trim.split(',').toList) // used from ide def clear(): Unit = (v = Nil) diff --git a/test/junit/scala/tools/nsc/reporters/WConfTest.scala b/test/junit/scala/tools/nsc/reporters/WConfTest.scala index 7a5547e85f82..c32220fe8ae7 100644 --- a/test/junit/scala/tools/nsc/reporters/WConfTest.scala +++ b/test/junit/scala/tools/nsc/reporters/WConfTest.scala @@ -215,8 +215,8 @@ class WConfTest extends BytecodeTesting { def lint(): Unit = { check(infos(code, "cat=lint:i"), Nil) check(infos(code, "cat=lint:i", lint = true), List(l2, l23)) - check(reports(code, "any:s,cat=lint:ws", lint = true), Nil) - check(reports(code, "cat=lint:ws,any:s", lint = true), List((-1, "2 lint warnings"))) + check(reports(code, "any:s,cat=lint:ws", lint = true), List((-1, "2 lint warnings"))) + check(reports(code, "cat=lint:ws,any:s", lint = true), Nil) check(infos(code, "cat=lint-deprecation:i", lint = true), List(l2)) check(infos(code, "cat=lint-adapted-args:i", lint = true), List(l23)) } From aeaacf8785e84fcac9fc4ffe8e10ec58e37a0593 Mon Sep 17 00:00:00 2001 From: Som Snytt Date: Fri, 8 Mar 2024 14:11:53 -0800 Subject: [PATCH 2/2] Adjust help text --- src/compiler/scala/tools/nsc/Reporting.scala | 7 +++++-- src/compiler/scala/tools/nsc/settings/Warnings.scala | 9 +++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/compiler/scala/tools/nsc/Reporting.scala b/src/compiler/scala/tools/nsc/Reporting.scala index ab76e08cc00b..057c4ca42701 100644 --- a/src/compiler/scala/tools/nsc/Reporting.scala +++ b/src/compiler/scala/tools/nsc/Reporting.scala @@ -522,6 +522,7 @@ object Reporting { def includes(o: WarningCategory): Boolean = this eq o def summaryCategory: WarningCategory = this lazy val name: String = WarningCategory.nameOf(this) + override def toString = name } object WarningCategory { @@ -722,7 +723,7 @@ object Reporting { } object MessageFilter { - object Any extends MessageFilter { + case object Any extends MessageFilter { def matches(message: Message): Boolean = true } @@ -768,7 +769,9 @@ object Reporting { } } - sealed trait Action + sealed trait Action { + override def toString = s"Action[${getClass.getSimpleName.stripSuffix("$")}]" + } object Action { object Error extends Action diff --git a/src/compiler/scala/tools/nsc/settings/Warnings.scala b/src/compiler/scala/tools/nsc/settings/Warnings.scala index 4829c7847f6d..baf83fedb5c0 100644 --- a/src/compiler/scala/tools/nsc/settings/Warnings.scala +++ b/src/compiler/scala/tools/nsc/settings/Warnings.scala @@ -82,8 +82,13 @@ trait Warnings { |The default configuration is: | -Wconf:${WconfDefault.mkString(",")} | - |User-defined configurations are added to the left. The leftmost rule matching - |a warning message defines the action. + |Under -Xsource:3-cross, the category of scala3-migration warnings are errors by default: + | -Wconf:cat=scala3-migration:e + |Under -Xsource:3-migration, they are warnings: + | -Wconf:cat=scala3-migration:w + | + |User-defined configurations override previous settings, such that the last matching + |configuration defines the action for a given diagnostic message. | |Examples: | - change every warning into an error: -Wconf:any:error