Multiplatform comparable object with typealias problem

Hi

I’m trying to make a multiplatform project with a DateTime object backed by a org.joda.DateTime object on the JVM side:

expect class DateTime : Comparable<DateTime> {
    fun getMillis(): Long
}

and in the JVM module:

actual typealias DateTime = org.joda.time.DateTime

But it complains about the comparable interface, how would you do this setup?

/Jakob

The reason is that org.joda.time.DateTime implements Comparable<ReadableInstant> rather than Comparable<DateTime>. Currently the exact match of the implemented interface is required.

You can try to introduce some expect interfaces to reflect the exact hierarchy of that DateTime:

expect interface ReadableInstant : Comparable<ReadableInstant>
expect interface ReadableDateTime : ReadableInstant
expect class DateTime : ReadableDateTime 

Meanwhile I’ve added this use case to the relevant issues: KT-21937 and KT-20641.

Hi Ilya

Thanks for clarifying and adding the usecase to the issues, i look forward to a resolution to these :slightly_smiling_face:

/Jakob