christophsturm
04/28/2021, 3:50 PM@DslMarker
annotation class MyDSL
@MyDSL
interface RootOnly {
fun rootOnly()
}
interface RootAndLeaf : RootOnly {
fun call(function: Leaf.() -> Unit)
fun rootAndLeaf()
}
@MyDSL
interface Leaf {
fun leaf()
}
val block: RootAndLeaf.() -> Unit = {
call {
leaf()
rootAndLeaf() // cannot be called by implicit receiver
}
}
Roukanken
04/28/2021, 7:39 PMleaf()
starts being blocked and rootAndLeaf()
works
if you just want to fix it tho, it's easy to just flip the inheritance. eg, Root
, Leaf
inheriting from RootAndLeaf
fixes stuff, and makes more sense to model it like that