I am also still playing around with context receiv...
# language-evolution
d
I am also still playing around with context receivers. If I wanna use the context receiver in constructor initializers I have to qualify the context object with
this@DslCtxObj.prop.func()
. Is this "on purpose" or is this just "not implemented yet" ?
Copy code
context(DslCtxObj)
class DslModel(arg: String = this@DslCtxObj.prop.func())
I would expect the following to work (but it doesn't)
Copy code
context(DslCtxObj)
class DslModel(arg: String = prop.func())
e
Not implemented yet
d
Hi @elizarov just for mentioning (almost sure, that the implementing team is aware of it, and there is a story/bug for it) Although above
this@CtxObj.doSomthing()
in constructor initializers does compile, it explodes at runtime with
Exception in thread "main" java.lang.VerifyError: Bad type on operand stack
Copy code
context(DslCtxWrapper)
class DslModelgroup(
    val simpleName: String,
    // exploding:
    val dslDelegate: DslDelegate = this@DslCtxWrapper.dslCtx.ctxObjOrCreate(simpleName, "modelgroupRef")
    val dslDelegate: DslDelegate = with(this@DslCtxWrapper) { dslCtx.createDslDelegate(simpleName, "modelgroupRef") }
    // working:
    val dslDelegate: DslDelegate = with (DslCtxWrapper(DslCtx(), DslDiscriminator("fake"))) { dslCtx.createDslDelegate(simpleName, "modelgroupRef") }
    val dslDelegate: DslDelegate = with (DslCtxWrapper(DslCtx(), DslDiscriminator("fake"))) { DslDelegate(simpleName, "modelgroupRef") }
) {
}
if you're not aware (as I said, don't think so) I am happy to file a bug 🙂 (I also have a standalone file for demonstration)