Why it doesn't allow to refer `smth` if I perform ...
# announcements
a
Why it doesn't allow to refer
smth
if I perform cast in the parentheses?
Copy code
sealed class Foo {
    data class Bar(val smth: Any) : Foo()
}

fun test(key: Any) {
    //key as Foo
    when (key as Foo) {
        is Foo.Bar -> key.smth
    }
}