danneu
02/05/2017, 12:29 AM@DslMarker
annotation class ParentDsl
@DslMarker
annotation class ChildDsl
@ParentDsl
class Parent(block: Parent.() -> Unit) {
init { this.block() }
fun parentOnly() = println("hello world")
fun child(block: Child.() -> Unit) {
val child = Child()
child.block()
}
}
@ChildDsl
class Child
val parent = Parent {
child {
// How to make this impossible?
parentOnly()
}
}