Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: reversed wconf parsing order to mirror scala 2 #18503

Merged
merged 1 commit into from
Sep 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading