So, I have one file where I added extension on some class. Something like
val A.extension
get = 1+1
And I get warning Receiver parameter is never used that I want to suppress. I tried multiple wild guesses like @file:Suppress("UNUSED_PARAMETER") but nothing worked.
Does someone know which string I am looking for? Second part of the question: Is there full list of suppress warnings? Usually there are only hardcoded strings, that I find all over internet, but not list suppress key - suppress description.
EDIT: I know suppress "unused" would do the work, but it is too generic.
EDIT2: I want to suppress specific warning in the whole file, I think it "unused" too generic in way that if I have A.extension and extension is never used, I want it gray(Property unused), but I do not want to have A gray (Receiver parameter unused).
The answer given above about using @receiver:Suppress("Unused")
was indeed the best solution until the recent Android Studio
update.
I found out that @Suppress("UnusedReceiverParameter")
can be used to achieve the same effect (i.e. suppressing the receiver parameter usage without affecting the unused status of the function itself). Personally, I think this change is for the better as it doesn't interfere with the function signature declaration.
So, I found it finally. It is possible to suppress things just for receiver with adding annotation @receiver:Suppress("Unused")
val @receiver:Suppress("Unused") A.extension
get = 1+1
And it will still get grayed out if extension is not used.
Edit: I aded my response before V Mircan answer, but I think his annotation is better.
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