Skip to content

Commit f49b27b

Browse files
fix: Closes #18367 -Wconf options are processed incorrectly
1 parent 89e8dba commit f49b27b

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

compiler/src/dotty/tools/dotc/reporting/WConf.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ object WConf:
106106
def fromSettings(settings: List[String]): Either[List[String], WConf] =
107107
if (settings.isEmpty) Right(WConf(Nil))
108108
else
109-
val parsedConfs: List[Either[List[String], (List[MessageFilter], Action)]] = settings.map(conf =>
109+
val parsedConfs: List[Either[List[String], (List[MessageFilter], Action)]] = settings.reverse.map(conf =>
110110
val filtersAndAction = conf.split(':')
111111
if filtersAndAction.length != 2 then Left(List("exactly one `:` expected (<filter>&...&<filter>:<action>)"))
112112
else

compiler/test/dotty/tools/dotc/config/ScalaSettingsTests.scala

+14
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,18 @@ class ScalaSettingsTests:
8383
val nowr = new Diagnostic.Warning("This is a problem.".toMessage, util.NoSourcePosition)
8484
assertEquals(Action.Silent, sut.action(nowr))
8585

86+
@Test def `i18367 rightmost WConf flags take precedence over flags to the left`: Unit =
87+
import reporting.{Action, Diagnostic}
88+
val sets = new ScalaSettings
89+
val args = List("-Wconf:cat=deprecation:e", "-Wconf:cat=deprecation:s")
90+
val sumy = ArgsSummary(sets.defaultState, args, errors = Nil, warnings = Nil)
91+
val proc = sets.processArguments(sumy, processAll = true, skipped = Nil)
92+
val conf = sets.Wconf.valueIn(proc.sstate)
93+
val msg = "Don't use that!".toMessage
94+
val depr = new Diagnostic.DeprecationWarning(msg, util.NoSourcePosition)
95+
val sut = reporting.WConf.fromSettings(conf).getOrElse(???)
96+
assertEquals(Action.Silent, sut.action(depr))
97+
98+
99+
86100
end ScalaSettingsTests

0 commit comments

Comments
 (0)