Remove Warning of Variable Shadowing in Kotlin

Viewed 3824

I couldn't find this info anywhere else.

Variable shadowing is a great feature in my opinion, yet in Kotlin we get warned for it every single time, thus requiring us to use @Suppress("NAME_SHADOWING") in every instance of it, if we wouldn't like it to warn us.

Is there a way to disable variable shadowing verifications, or suppress the warning globally?

1 Answers

From Annotations in Kotlin

Put an annotation with the target file at the top level of a file, before the package directive or before all imports if the file is in the default package:

So right now the only solution is you can disable Suppress for file level. I don't find any way to disable for projects.

@file:Suppress("NAME_SHADOWING")
package com.your.package.name

import android.content.Context
import android.content.Intent
import android.os.Bundle

class SplashActivity : AppCompatActivity() {
    // Your class code here
}
Related