bug icon indicating copy to clipboard operation
bug copied to clipboard

-Xlint:cloneable ignores -Wconf:any settings

Open coreywoodfield opened this issue 10 months ago • 3 comments

Reproduction steps

Scala version: 2.13.13

object Bar extends Cloneable {
  def f: Unit = {}
}
$ scalac Test.scala -Xlint -Wconf:any:error
Test.scala:1: warning: object Bar should not extend Cloneable.
object Bar extends Cloneable {
       ^
Test.scala:2: error: side-effecting nullary methods are discouraged: suggest defining as `def f()` instead [quickfixable]
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=lint-nullary-unit, site=Bar
  def f: Unit = {}
      ^
1 warning
1 error
$ scalac Test.scala -Xlint -Wconf:any:silent
Test.scala:1: warning: object Bar should not extend Cloneable.
object Bar extends Cloneable {
       ^
1 warning

Problem

-Xlint:cloneable level isn't changed by -Wconf:any settings, whereas -Xlint:nullary-unit and every other lint setting I've tested is

coreywoodfield avatar Apr 11 '24 18:04 coreywoodfield

I'm aware that -Wconf originally configured configurable warnings, which were warnings normally collected for a "summary" report. If -Wconf can configure any warning, then all warnings must be treated the same way, including warnings that don't have a summary report.

som-snytt avatar Apr 11 '24 18:04 som-snytt

https://github.com/scala/scala/blob/v2.13.13/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala#L905

should use runReporting.warning

lrytz avatar Apr 15 '24 08:04 lrytz

... should use refchecksWarning ...

I admit I avoid the overloaded runReporting.warning because of decision fatigue.

som-snytt avatar Apr 15 '24 21:04 som-snytt