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