So I'm trying to implement a platform-specific class with specific generic types and having some problems doing that, mainly because the
expected
declaration needs to match the
actual
type-specific one, which obviously does not work. Here is an example:
Copy code
// common
interface SomeType
abstract class AbstractTypeWrapper<T: SomeType> {
protected abstract fun instantiate(): T
}
expect class TypeWrapper : AbstractTypeWrapper<SomeType>
^^^--- this is obviously different
// android
interface AndroidType: SomeType
actual class TypeWrapper : AbstractTypeWrapper<AndroidType>() {
override fun instantiate(): AndroidType {
// ...
}
}
// desktop
interface DesktopType: SomeType
actual class TypeWrapper : AbstractTypeWrapper<DesktopType>() {
override fun instantiate(): DesktopType {
// ...
}
}