Hi all I am having trouble with an object getting ...
# kotlin-native
w
Hi all I am having trouble with an object getting frozen in its
init
block and then top level value assignments causing an exception. heres a min example:
Copy code
class Foo(bar: Bar) {
    init {
        CoroutineScope(Dispatchers.Default).launch { 
            bar.buzz()
        }
    }
    
    val a = 3
}
in the init block since bar is accessed, it seems like that is causing the entire foo object to also get frozen then when it gets to
val a = 3
during runtime - it complains about foo instance already being frozen. how can i go about fixing this?
got help in #multiplatform
t
Copy code
class Foo(bar: Bar) {
    init {
        val bar = bar
CoroutineScope(Dispatchers.Default).launch { 
            bar.buzz()
        }
    }
    val a = 3
}
get it into local scope