Reputation: 17676
how can I actually suppress the compiler warning for:
discarded non-Unit value
[warn] kryo.register(classOf[Foo])
The suggestion of Suppress "discarded non-Unit value" warning does not apply since the problem takes place outside of my own code.
compiler options are:
"-target:jvm-1.8",
"-encoding",
"UTF-8",
"-feature",
"-unchecked",
"-deprecation",
"-Xfuture",
"-Xlint:missing-interpolator",
"-Yno-adapted-args",
"-Ywarn-dead-code",
"-Ywarn-numeric-widen",
"-Ywarn-value-discard",
"-Ywarn-dead-code",
"-Ywarn-unused"
which will warn "-Ywarn-value-discard",
Upvotes: 1
Views: 1542
Reputation: 1213
You should just return Unit
explicitly from the block where you call kryo.register
. If there is no block, wrap it in one:
{
kryo.register(classOf[Foo])
kryo.register(classOf[Bar])
() // I know what I'm doing
}
Unfortunately Scala has no built-in suppression system. People have been asking for this but it's not trivial to achieve. For now there are two options:
Upvotes: 3