Kotlin works around this problem by only allowing this when value is an immutable local or stored variable, and not when it’s mutable or has a getter. In Swift terms, only lets can do narrowing here, not vars (and obviously not return values from functions).
1 Like