I found some issues with smart cast, here two examples:
fun exampleElse(vararg args: String) {
val something: Any = TODO()
if (something is String) throw Exception()
else // <---
if (something !is Long) throw Exception()
something.dec()
}
fun exampleWhen(vararg args: String) {
val something: Any = TODO()
when (something) {
!is Long -> throw Exception()
}
something.dec()
}
In the first example it is possible to invoke dec() but, when else is not commented, the IntelliJ’s auto completition fails.
In the second case smart cast fails indifferently.
The comment probably changes whether the if is independent or not. Without the comment it will be part, and analysis of multiple if statements may be incomplete (in actuality the analysis is quite tricky.
For the second one, it is clear that this is also not analysed completely.