is it on purpose (and if so why) that I cannot use...
# language-evolution
d
is it on purpose (and if so why) that I cannot use the context object for assigning constructor default values, BUT I CAN use it in class init { } block??? ctxObjs access does NOT work in constructor:
Copy code
class CtxClass(val value: Int)

data class CtxStore(val ctxObjs: MutableMap<String, CtxClass> = mutableMapOf())

context(CtxStore)
class SomeClass(var ctxO: CtxClass = ctxObjs["someRef"]!!) { // <-- Unresolved reference: ctxObjs
    fun someFun() = "SomeClass(${ctxO.value})"
}
ctxObjs access does work in init block:
Copy code
class CtxClass(val value: Int)

data class CtxStore(val ctxObjs: MutableMap<String, CtxClass> = mutableMapOf())

context(CtxStore)
class SomeClass(var ctxO: CtxClass = CtxClass(0)) {
    init {
        ctxO = ctxObjs["someRef"]!!
    }
    fun someFun() = "SomeClass(${ctxO.value})"
}
e
No. It is just not implemented in a prototype.