Skip to content

-Wconf options are processed incorrectly #18367

Closed
@coreywoodfield

Description

@coreywoodfield

Compiler version

3.3.0

Minimized code

object Main {
  def main(args: Array[String]): Unit = Deprecated.deprecated
}

object Deprecated {
  @deprecated("", "")
  def deprecated = ()
}

(anything that will produce a warning that can be configured with -Wconf will do)

Output

scala 2.13.10

$ scala-2.13.10/bin/scalac -Wconf:cat=deprecation:e -Wconf:cat=deprecation:s Test.scala

$ scala-2.13.10/bin/scalac -Wconf:cat=deprecation:s -Wconf:cat=deprecation:e Test.scala
Test.scala:3: error: method deprecated in object Deprecated is deprecated:
  def main(args: Array[String]): Unit = Deprecated.deprecated
                                                   ^
1 error

scala 3.3.0

$ scala3-3.3.0/bin/scalac -Wconf:cat=deprecation:e -Wconf:cat=deprecation:s Test.scala
-- Error: Test.scala:3:51 -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
3 |  def main(args: Array[String]): Unit = Deprecated.deprecated
  |                                        ^^^^^^^^^^^^^^^^^^^^^
  |                                        method deprecated in object Deprecated is deprecated since : 
1 error found

$ scala3-3.3.0/bin/scalac -Wconf:cat=deprecation:s -Wconf:cat=deprecation:e Test.scala

Expectation

In scala 2, passing -Wconf:cat=deprecation:silent after -Wconf:cat=deprecation:error would override the error setting, i.e. the last provided configuration wins. In scala 3, the opposite is true: the first provided configuration wins. The documentation for the behavior is the same for both: scalac -Wconf:help includes the following:

User-defined configurations are added to the left. The leftmost rule matching
a warning message defines the action.

I would expect that, having the same documentation, the -Wconf flags would be handled in the same order. The scala 2 behavior is useful for providing a general default (e.g. -Wconf:any:error) and then being able to append more specific options to the scalac options and have those override the general default. A bit more discussion can be found in #18365

Metadata

Metadata

Assignees

No one assigned

    Labels

    SpreeSuitable for a future Spreegood first issuePerfect for someone who wants to get started contributingitype:enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions