My class has var label: String? = null. Inside a method I write if (label != null) { print(label.length) } and the compiler refuses: smart cast is impossible because label is a mutable property that could have been changed by this time. The same code compiles when label is a local variable.
I have just checked it for null on the previous line. What is the compiler worried about, and what is the idiomatic way to write this without sprinkling !! everywhere?




