You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
3.3.0 with compiler options -Wvalue-discard and -Xfatal-warnings
Minimized code
importscala.collection.mutableimportscala.annotation.nowarnobjectFoo:deff(b: Boolean):String=valmessageBuilder= mutable.StringBuilder()
if b then// Here @nowarn is effective with or without -Wfatal-warnings// i.e. no warning without -Wfatal-warnings and no error with -Wfatal-warnings
messageBuilder.append("helloworld").append("\n"):@nowarn("msg=discarded non-Unit value*")
messageBuilder.result()
defg(x: String=>Unit) =???defh:String=valmessageBuilder= mutable.StringBuilder()
g: s =>// here @nowarn is effective without -Wfatal-warnings (i.e. no warning)// But with -Wfatal-warnings we get an error
messageBuilder.append("\n").append(s):@nowarn("msg=discarded non-Unit value*")
messageBuilder.result()
Compiler version
3.3.0 with compiler options
-Wvalue-discard
and-Xfatal-warnings
Minimized code
Scastie: https://scastie.scala-lang.org/yHZ6xz51SsKqKpHaXaPJQQ
Output
Expectation
When a warning is silenced with a
@nowarn
annotation, it should not raise an error when-Wfatal-warnings
flag is usedNotes
I noticed that code like:
Do not give a warning, while:
does give a warning.
Not sure if that's expected.
The text was updated successfully, but these errors were encountered: