interface Status {
fun signal() = println("signal")
}
interface Ok : Status
interface Postponed : Status
interface Declined : Status
// *** before: ***
fun checkOld(status: Any) {
if (status is Postponed || status is Declined) {
//status.signal() // <- Error: only the members of Any were
//available
(status as Status).signal()
}
}
// *** in version 2.0: ***
fun check(status: Any) {
if (status is Postponed || status is Declined) {
status.signal() // smart cast to the common supertype Status
}
}