Kotlin smart cast with nullable variable
问题 When I'm trying to create the following code: class SmartCast { var array: MutableList<Int>? = null fun processArray() { if (array != null && !array.isEmpty()) { // process } } } this error is shown: Smart cast to 'MutableList' is impossible, because 'array' is a mutable property that could have been changed by this time It's clear that the array variable can be changed to null in case of multi-threading. But if I use @Synchronized annotation, there is no way to mutate the variable in between