import scala.annotation.nowarn
class C {
def f =
try ???
catch { case _: NullPointerException => }: @nowarn
def g =
try ???
catch { case _: NullPointerException => }: @nowarn("cat=w-flag-value-discard")
}
Problem
catchem.scala:10: warning: This catches all Throwables. If this is really intended, use `case _ : Throwable` to clear this warning.
catch { case _: NullPointerException => }: @nowarn("cat=w-flag-value-discard")
^
1 warning
Warns at g but not at f. The correct code adds parens (try ??? catch { ... }): @nowarn.
Reproduction steps
Scala version: 2.13.11
Problem
Warns at g but not at f. The correct code adds parens
(try ??? catch { ... }): @nowarn
.