kotlin-language-server icon indicating copy to clipboard operation
kotlin-language-server copied to clipboard

Smart Casts

Open Xandaros opened this issue 3 years ago • 0 comments

Currently, the language server does not seem to respect smart casts.

fun test() {
    class Test() {
        var qwe: Int = 5
    }
    val asd = Test()
    val fgh = asd as Any
    if (fgh !is Test) {
        return
    }
    fgh.qwe = 6
}

Hovering over fgh at the very bottom tells me the type is Any, when it should be inferred to actually be Test at this point. While typing that line, qwe is also never suggested as an option. No diagnostics are shown for the completed code, however, so that is good at least.

Xandaros avatar Sep 08 '22 15:09 Xandaros