How come Kotlin contracts are not working anymore?...
# getting-started
How come Kotlin contracts are not working anymore? These have been working fine a few months back.
Interesting. I don't think that's ever worked for me. Because
is a class property, it could have mutated between the
and usage. I usually need to do:
Copy code
val channel = requireNotNull(

channel.?let { // use }
­čĹŹ 1
I usually do that ?.let pattern also. But it doesn't always end in the cleanest code. I did use the contracts like shown on the image some months ago. So there is something that has changed. But yeah, I will go ahead and do
val channel = requireNotNull(
instead of having
all the time ­čÖé
smart casting should work on non-captured locals,
Copy code
fun foo() {
    var bar: Int?
    bar = 1
but you can't prove that class properties won't be mutated by anybody else