Search code examples
kotlinkotlin-null-safety

Kotlin 'unsafe call on nullable receiver' compile error after null check


This is the screenshot of the error: Error Screenshot

I'm using Intellij v14.0.1 + Kotlin plugin v0.9.206. My understanding is that after the null check, the compiler shouldn't show me the error. Am I wrong?


Solution

  • target property is var, that's why it's not guarantee that on the third line this property couldn't be null (e.g. another thread could set it to null)