I'm developing an android app using Kotlin.
I have two different build-variants - VariantA
and VariantB
- both containing a configuration-File:
// VariantA
object ConfigEnvironment {
val SOME_PARAMETER: String? = null
}
// VariantB
object ConfigEnvironment {
val SOME_PARAMETER: String = "This is a config"
}
In my code i'm calling:
ConfigEnvironment.SOME_PARAMETER?.let { Log.d("tag", "$it" }
When building VariantB the Compiler throws a warning:
Safe call on a non-null receiver will have nullable type in future releases
While this is correct for this variant, it's somewhat impractical - since i need the nullability in the other variant.
Can i safely supress this lint? (And how do i do that? My IDE didn't suggest any fixes)
It should be safe to suppress this warning since you do not call something which expects a non-nullable expression for
it
inside thelet
.You can suppress the warnung like this:
IntelliJ can help you with that. Just move the cursor to the
?.
and type your shortcut for Quick Fix (you can look it up in the Keyboard settings):