```fun main{ val scope = getScope() when(s...
# getting-started
m
Copy code
fun main{
    val scope = getScope()
    when(scope){
        // scope not smartcast and thus error
        is DeeperScope.Impl1, is DeeperScope.Impl2 -> scope.someVar = "2" 
    }
}

interface Scope
sealed interface DeeperScope : Scope{
    var someVar: String
    data class Impl1(override var someVar: String) : DeeperScope
    data class Impl2(override var someVar: String) : DeeperScope
}
fun getScope() : Scope = DeeperScope.Impl2("2")
Why can't scope be smartcast to DeeperScope in the when? Both implementations have their common parent as DeeperScope
e
m
wow a 10 year old ticket for something that seems quite trivial
d
Such smartcasts will be avaliable in K2 compiler
👌 4