Hey! I'm running into an inheritance cycle error w...
# multiplatform
u
Hey! I'm running into an inheritance cycle error with
Props.View
. Here's my code:
Copy code
class Props(
    override val map: MutableMap<String, JsonElement>,
    override val json: Json = Json
) : SerializableTypeSafeProperties, TypedGeoProperties, Props.View {
    interface View {
        val id: Id.V2?
        val title: String?
        val distance: Float?
        val ascent: Float?
        val descent: Float?
        val color: String?
        val width: Int?
    }

    override var id by serializable<Id.V2>("uuid")
    override var title by string("title")
    override var distance by float("distance")
    override var ascent by float("ascent")
    override var descent by float("descent")
    override var color by string("style-color")
    override var width by int("style-width")
}
For context, I'm using these definitions:
Copy code
typealias GeoProperties = Map<String, JsonElement>

interface TypedGeoProperties {
    val map: GeoProperties
}
And
TypeSafeProperties
just provides default interface implementations for these delegates. Error message says: "There's a cycle in the inheritance hierarchy for this type [Props.View]" Any ideas what's causing this?
p
If you take the interface View definition out of Prop class, do you still get the same error?
u
Moving it up fixes it
But just in general, why is this happening?
There should be no dependency here
p
Right you have a class definition recursion Class A depends on class B but class B also depends on class A. So egg and chicken, the compiler doesn't know what definition to create first.
I side with you , the fact that View is an interface shouldn't have a dependency Props
Perhaps worthy asking in #C7L3JB43G
🙌 1