Another possible optional inference improvement


#1

I just wrote a code like this:

val chosenProfile = /* some expression that can be null, i.e. QQQ? */

    if (chosenProfile?.likesUser == true) {
    .....
        this.foo(chosenProfile, extra)

The compiler says “Error:(316, 32) Type mismatch: inferred type is QQQ? but QQQ was expected”.

I think it can be inferred that if the program reaches here, the type is QQQ.


#2

this was with kt 1.0.4


#3

This improvement is already implemented in 1.1, if I’m not mistaken.