Is it possible to suppress this specific warning by using @SuppressWarnings(???)
? (I don't intend to use this conversion as a view bound, so the warning isn't useful.)
Unfortunately not. The compiler ignores @SuppressWarnings
. Also see this question.
While you cannot suppress this warning through @SuppressWarnings
, you can simply rename one of the overloads that the compiler is warning about. If you don't want to rename it because it is also explictly called, make the method non-implicit and add another (differently named) implicit conversion that forwards to the former.
In other words, you should by example turn this:
class MyClass
object MyClass {
implicit def myConv: MyClass = error("TODO")
implicit def myConv[X](value: X): MyClass = error("TODO")
}
into this:
class MyClass
object MyClass {
implicit def myConv: MyClass = error("TODO")
def myConv[X](value: X): MyClass = error("TODO") // made it non implicit
implicit def myConv2[X](value: X): MyClass = myConv( value ) // renamed so that it is not an overload anymore
}
Note that the warning is only emitted in scala 2.9.x, it is by default not emitted anymore in scala 2.10 (but the actual problem that the warning is talking about is still there - the warning message was only removed because it was deemed too noisy with the new surge in type class usage).
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