Use of @SuppressWarnings is to suppress or ignore warnings coming from the compiler, i.e., the compiler will ignore warnings if any for that piece of code. 1. @SuppressWarnings("unchecked") public class Calculator { } - Here, it will ignore all unchecked warnings coming from that class.
If you choose to put @SuppressWarnings("rawtypes") at the method level, Eclipse will suppress all raw-types warnings inside that method. If we compile same code without @SuprressWarnings, using javac compiler it will show the following hint: $ javac RawType.
null to suppress warnings relative to null analysis. restriction to suppress warnings relative to usage of discouraged or forbidden references. serial to suppress warnings relative to missing serialVersionUID field for a serializable class. static-access to suppress warnings relative to incorrect static access.
No, and an enhancement request [1] for such a feature was closed as wontfix
.
I agree it would be useful. I expect that the Scala core team aren't against the idea, but they have finite resources and many higher priorities.
update: this feature was eventually implemented in scala 2.13.2 release on 2020-04-22, see this answer
[1] https://issues.scala-lang.org/browse/SI-1781
EDIT: You should use @nowarn
There is a simple compiler plugin for this: silencer (a bit shameless plug)
Scala 2.13.2 provides @nowarn
annotation developed on the basis of ghik's silencer
, for example
import scala.annotation.nowarn
def t = { 0: @nowarn; 1 }
raises no warnings, whilst
def t = { 0; 1 }
gives
warning: a pure expression does nothing in statement position; multiline expressions might require enclosing parentheses
def t = { 0; 1 }
^
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With