Scala3: `-Wall` is inconsistent with `-Wshadow` and `-Wunused`

Not sure if it is a bug or not. If yes, I’ll be glad to file it on GitHub.

According to scala-cli -S 3.7.nightly -O -W:

  • -Wall Enable all warning settings.
  • -Wshadow Enable or disable specific shadow warnings
  • -Wunused Enable or disable specific unused warnings

The way I get it is that -Wall should imply both -Wshadow:all and -Wunused:all.
However for now it imlplies -Wunused only but not -Wshadow:

//> using scala 3.7.nightly
//> using options -Wshadow:all -Wunused:all

class A:
  protected val x: String = ""

class B extends A:
  private val x: Int = 0

produces the following output:

-- Warning: .../wall-wshadow-wunused.scala:8:2 
8 |  private val x: Int = 0
  |  ^
  |  value x in class B shadows field x inherited from class A
-- [E198] Unused Symbol Warning: .../wall-wshadow-wunused.scala:8:14 
8 |  private val x: Int = 0
  |              ^
  |              unused private member
2 warnings found

However if -Wshadow:all and -Wunused:all are replaced with -Wall:

//> using scala 3.7.nightly
//> using options -Wall

// --- the rest is the same as above ---

then only the “unused” warning is reported:

-- [E198] Unused Symbol Warning: .../wall-wshadow-wunused.scala:8:14 
8 |  private val x: Int = 0
  |              ^
  |              unused private member
1 warning found

It also works the same way with both the stable v3.7.4 and v3.8.nightly.

Yes, I agree it’s worth a ticket.

I don’t know why shadow has a separate mechanism, and this may just be a bug.

The other issue is that in Scala 2 -Wall was retracted (in the distant past) because warnings tend to be flaky or imprecise or noisy. They added -Xlint to mean “warnings known not to be too noisy”.

I think that is a practically useful distinction, and I don’t know if shadow was deemed too noisy.

I don’t know why Scala 3 doesn’t like -Xlint; it was added and dropped.

1 Like

Thank you for the feedback!
I created a new issue #24466.