I am trying to give the "parent" block ability to ...
# dsl
d
I am trying to give the "parent" block ability to implement the same closure(s) as their "child" block, but restricting to certain interfaces. I of course can give the parent an implementation which implements all interface "flavours", and still restrict the children to more specific interfaces ... everything works out, but then, DESPITE having @DslMarkers on ALL my classes, child-blocks STILL see clauses of the parent WITHOUT explicitly qualifying them (
<mailto:this@dsl.xxx|this@dsl.xxx>
) and I don't understand WHY. I constructed a single executable File to showcase my "problem" (at the end of the file/code)
the "problem" is even more visible, when you (uncomment) to let
DslClass
itself delegate BOTH interfaces:
Copy code
IDelegationIfcSpecialAndCommon by dslClassDelegateImpl
common { name..Special {
is visible without
this@dsl.
and
special { name...Common {
is also visible without
this@dsl.
Why is this?
official docs say:
To make the compiler start controlling scopes you only have to annotate the types of all receivers used in the DSL with the same marker annotation.
which I think I did, so that:
..., the Kotlin compiler knows which implicit receivers are part of the same DSL and allows to call members of the nearest receivers only
(so why does it allow the implicit receiver of the parent
DslClass
in my example code I gave?