Skip to content

Commit

Permalink
fix: Closes #18367 -Wconf options are processed incorrectly
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmatthiggins committed Sep 3, 2023
1 parent 89e8dba commit f49b27b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/reporting/WConf.scala
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ object WConf:
def fromSettings(settings: List[String]): Either[List[String], WConf] =
if (settings.isEmpty) Right(WConf(Nil))
else
val parsedConfs: List[Either[List[String], (List[MessageFilter], Action)]] = settings.map(conf =>
val parsedConfs: List[Either[List[String], (List[MessageFilter], Action)]] = settings.reverse.map(conf =>
val filtersAndAction = conf.split(':')
if filtersAndAction.length != 2 then Left(List("exactly one `:` expected (<filter>&...&<filter>:<action>)"))
else
Expand Down
14 changes: 14 additions & 0 deletions compiler/test/dotty/tools/dotc/config/ScalaSettingsTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,18 @@ class ScalaSettingsTests:
val nowr = new Diagnostic.Warning("This is a problem.".toMessage, util.NoSourcePosition)
assertEquals(Action.Silent, sut.action(nowr))

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



end ScalaSettingsTests

0 comments on commit f49b27b

Please sign in to comment.