interface Foo { val isValid: Boolean } fun test(obj: Any) { if (obj is Foo && obj.isValid) { consume(obj) } } fun consume(obj: Foo) {}