Shouldn't foo be smart cast to non-null in the sec...
# announcements
l
Shouldn't foo be smart cast to non-null in the second condition?
Also, if I apply one of the quick fixes suggested by IntelliJ, I get this
c
that does look odd... but I couldn't reproduce it here: https://pl.kotl.in/hRwiWg4Z3 what version of Kotlin are you using?
l
1.3.72-release-IJ2020.1-1
c
I ran the same version in the playground and it works fine. very strange! 🤷
🤔 1
d
Is that ..... a member variable?
d
Smart cast don't work on member variables! You have to make local copy.
if (a.foo?.invoke(4) != false)
You could also do this. Not sure if I recommend it though.
l
Oh, I thought that only applied to
var
members 🤷‍♂️ Thanks!
s
Strange... Maybe same issue/cause as mentioned in the previous thread? https://youtrack.jetbrains.com/issue/KT-38134
🤷‍♂️ 2