Is there an equivalent to SuppressWarnings in Scala?

前端 未结 4 1097
感动是毒
感动是毒 2020-12-05 12:30

I was wondering if scala had an equivalent to java\'s @SuppressWarnings that can be applied to a function or whatever to ignore any deprecation warnings[1] that function emi

4条回答
  •  眼角桃花
    2020-12-05 13:10

    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 }
                ^
    

提交回复
热议问题