Skip to content

Commit

Permalink
Let -Wall override -Wunused
Browse files Browse the repository at this point in the history
  • Loading branch information
Linyxus committed Jul 2, 2024
1 parent 81f2c8e commit fe15294
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/config/ScalaSettings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ private sealed trait WarningSettings:
def nowarn(using Context) = allOr("nowarn")

// Is any choice set for -Wunused?
def any(using Context): Boolean = Wunused.value.nonEmpty
def any(using Context): Boolean = Wall.value || Wunused.value.nonEmpty

// overrided by strict-no-implicit-warn
def imports(using Context) =
Expand Down
8 changes: 8 additions & 0 deletions tests/warn/i18559c.check
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
-- [E198] Unused Symbol Warning: tests/warn/i18559c.scala:4:28 ---------------------------------------------------------
4 | import collection.mutable.Set // warn
| ^^^
| unused import
-- [E198] Unused Symbol Warning: tests/warn/i18559c.scala:8:8 ----------------------------------------------------------
8 | val x = 1 // warn
| ^
| unused local definition
-- [E198] Unused Symbol Warning: tests/warn/i18559c.scala:11:26 --------------------------------------------------------
11 | import SomeGivenImports.given // warn
| ^^^^^
| unused import
6 changes: 3 additions & 3 deletions tests/warn/i18559c.scala
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
//> using options -Wall -Wunused:locals
// This test checks that -Wall leaves -Wunused:... untouched if it is already set
// This test checks that -Wall overrides -Wunused:... if it is already set
object FooImportUnused:
import collection.mutable.Set // not warn
import collection.mutable.Set // warn

object FooUnusedLocal:
def test(): Unit =
val x = 1 // warn

object FooGivenUnused:
import SomeGivenImports.given // not warn
import SomeGivenImports.given // warn

object SomeGivenImports:
given Int = 0
Expand Down

0 comments on commit fe15294

Please sign in to comment.