You’re describing the Gang-of-Four Composite Pattern here…
It’s not really something that I’d think should be implemented at the language level for delegation, but might prove useful as a compiler plugin for an annotation (as it’s a very common pattern). Something like
@Composite(MyStuff::class)
class Container: MyStuff {
...
}
and the compiler plugin could generate children and myCall to make it effectively:
class Container: MyStuff {
var children: List<MyStuff>(); // optional arg to annotation to make this private
override fun myCall(...params...) {
children.forEach { it.myCall(...params...); }
}
...
}
Probably useful to do for a few other Design Patterns as well