Dirk Hoffmann
06/07/2023, 9:51 AMthis@DslCtxObj.prop.func()
.
Is this "on purpose" or is this just "not implemented yet" ?
context(DslCtxObj)
class DslModel(arg: String = this@DslCtxObj.prop.func())
I would expect the following to work (but it doesn't)
context(DslCtxObj)
class DslModel(arg: String = prop.func())
elizarov
06/07/2023, 10:25 AMDirk Hoffmann
06/10/2023, 10:52 AMthis@CtxObj.doSomthing()
in constructor initializers does compile, it explodes at runtime with Exception in thread "main" java.lang.VerifyError: Bad type on operand stack
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)