Home > Blockchain >  How to suppress operator overloading for get and set methods in Kotlin inspections?
How to suppress operator overloading for get and set methods in Kotlin inspections?

Time:12-16

I am trying to create a custom get and set method but I would like to suppress the inspections warning Function should have 'operator' modifier only for these specific functions.

The following did not work:

@Suppress("operator")
suspend fun get(key: K): V?

@Suppress("operator")
suspend fun set(key: K, value: V): String?

CodePudding user response:

This is an enter image description here

You will find the option "Suppress 'AddOperatorModifier' for fun get". Choosing it will insert the line:

@Suppress("AddOperatorModifier")

The inspection can also be disabled globally in the IntelliJ settings:

enter image description here

  • Related