Anyone had problems using kotlin classes on a thre...
# multiplatform
l
Anyone had problems using kotlin classes on a thread in swift, and having errors like : Uncaught Kotlin exception: kotlin.native.IncorrectDereferenceException: illegal attempt to access non-shared <object>@27c0f38 from other thread And after trying to annotate the class with either SharedImmutable or ThreadLocal getting -> @ThreadLocal is applicable only to property with backing field, to property with delegation or to objects
https://github.com/lschiavini/KmmKlibError check the concurrent branch to generate the problem
k
You need to freeze the class before passing it around threads outside of Kotlin.
l
As in calling freeze() directly on Kotlin?
p
You can also use coroutines and the new memory model and forget about freezing objects manually
❤️ 1