This is one of the many reasons why I've found Kotlin so refreshing after five years of writing enterprise Java
https://kotlinlang.org/docs/typecasts.html#smart-casts