I'm trying to find a way to bring multiple values ...
# announcements
r
I'm trying to find a way to bring multiple values into scope with inheritance. Currently this is what I'm doing:
Copy code
interface A {
    val prop1: ...
    val prop2: ...
    ...

    companion object : A {
        ...
    }
}

interface B : A {
    val prop3: ...
    ...

    companion object : B, A by A {
        ...
    }
}
Is there a way to do this without the weird interface / companion construct?
h
class
?
e
Does it need to be part of the interface or you just want to bring values into scope for internal use?
h
I meant, you can use a class for
A
and only your "last hierarchy level" needs to be an
object
. That way, you can inherit how deep you want (Example). But I'm probably not fully understanding what you're after…
s
How about composition instead of inheritance. B being a wrapper layer with its own props, and other others which are delegated to A
e
It's coming soon... 🙂
h
It's at least on the roadmap: https://youtrack.jetbrains.com/issue/KT-42435
e
@Ruckus the design proposal was published today: https://github.com/Kotlin/KEEP/issues/259