I face a problem with Intellij and extension function that implies not null on the receiver.
With this code snippet :
fun myFunction(myValue: String?) {
when {
myValue.isNullOrBlank() -> println("myValue is blank")
else -> println(myValue.length)
}
}
Intellij complains on the line ‘println(myValue.length)’ (Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type String?) while it build without errors with maven (and in Intellij with Ctrl + F9).
It seems the IDE ignore the contract and implies instructions in the isNullOrBlank() extension and considers that the myValue variable might be null in the else branch.
Am I missing out on something?
Thanks
Info :
- Intellij (2019.2.4)
- Kotlin 1.3.50