kotlinintellij-inspections

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


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?

Solution

  • This is an IntelliJ Inspection, and you can see options for turning it off by clicking on the light bulb, then clicking on the right arrow of the first drop down option.

    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