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 let
s can do narrowing here, not var
s (and obviously not return values from functions).
1 Like