https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
j

Jurriaan Mous

06/16/2019, 11:37 AM
I have a Java library which has the following signature:
public interface Options<T extends Options>
It uses
T
to return self so it can chain method calls. I want to make this interface available to multiplatform with expect/actual so I can also expose the implementing classes with Options interface with expect/actual through a typealias. The actual:
actual typealias Options<T> = AliasedOptions<T>
If I put
expect interface Options<T: Options<*>>
the actual succeeds but expect fails with
Violation of Finite Bound Restriction for Options
If I put
expect interface Options<T: Options<T>>
the expect succeeds but the actual fails with
Copy code
Actual typealias 'DBOptionsInterface' has no corresponding expected declaration
The following declaration is incompatible because upper bounds of type parameters are different:
    public expect interface Options<T : Options<T> /* = Options<T> */>
I have no control over the java library. Are there options to work around this? Or is my only option to copy all the expected methods to all implementing classes and ignore the interfaces?
In the end I ended up changing it in the original: https://github.com/facebook/rocksdb/pull/5461
4 Views