Implementation delegation of inherited interfaces


Suppose we have next interface:

interface TabsInfo : Iterable<Tab>

Then we can not write:

class TabsBuilder(
    private val tabs: Iterable<Tab> = mutableListOf()
) : TabsInfo by tabs {
    //...other code

I understand why. Because TabsInfo can extend Iterable by introducing new methods.
But apparently we can write:

class TabsBuilder(
    private val tabs: Iterable<Tab> = mutableListOf()
): TabsInfo, Iterable<Tab> by tabs {
   //...other code

So in general it is possible to provide delegation pattern for inherited interfaces.
The question is: is it planned or maybe is there a wish to plan supporting of delegation by for inherited interfaces, so first example will be acceptable. For example, if TabsInfo had additional method, then we need to implement it in TabsBuilder according to first and second examples, but we will not need to specify additional interface in TabsBuilder class declaration like in second example.Preformatted text


The first case doesn’t compile because you cannot delegate the implementation to something that doesn’t implement the interface.
But defining the type like: typealias TabInfo = Iterable<Tab> would’ve worked.


TabsInfo implements required interface. And, also, I can not convert TabsInfo interface to typealias, since it has additional methods.

The point is, that I can provide a delegation, but for that I need to explicitly say, that TabsBuilder implements Iterable<Tab>, although it already implements this interface, since it implements TabsInfo, which implements Iterable<Tab>


TabsInfo doesn’t implement anything. It’s an interface, not an implementation.
I meant MutableInterface does not implement TabsInfo because there is no structural typing in Kotlin, Classes have to declare the interfaces they implement.