Kotlin unsafe calling compile error using null receiver after null check

This is a screenshot of the error: Error Screenshot

I am using Intellij v14.0.1 + Kotlin plugin v0.9.206. I understand that after a null check, the compiler shouldn't show me an error. I am wrong?

+3


source to share


2 answers


target

property var

, so does not guarantee that in the third line this property cannot be null (e.g. another thread can set it to null

)



+1


source


AFAIK, a property can be a method call and then nothing can be guaranteed. Use local val

.



0


source







All Articles