Class Delegation and annotations

Hello,

Class Delegation looks great. The only thing, which I am missing is ability to add annotations to the some of the delegated methods. I am wondered if there is any was to write in in the way similar to custom getters/setters, where only method name and annotations is required, like following:

var setterWithAnnotation: Any? = null
    @Inject set // annotate the setter with Inject

If there is none and it sounds like feature request - does it makes sense for you to have it implemented by the Kotlin language?

As for me, it makes sense as docs say “Kotlin supports Class Delegation natively requiring zero boilerplate code”.

Taking the classes from docs as the base, desired result would be something like:

class Derived(b: Base) : Base by b {
     @JSFunction override fun print
}
1 Like