Is it possible for an expect declaration to use an...
# multiplatform
j
Is it possible for an expect declaration to use an interface, where the actual implementation implements the interface signature? For example:
Copy code
// commonMain

expect class FooClass : BarInterface {
    fun fooFun()
}

interface BarInterface {
    fun barFun()
}

// androidMain

actual typealias FooClass = FooImpl

class FooImpl {
    fun fooFun() {}
    fun barFun() {}
}
I get the error on `typealias FooClass`:
Copy code
Actual typealias 'FooClass' has no corresponding expected declaration The following declaration is incompatible because some supertypes are missing in the actual declaration:
public final expect class FooClass : BarInterface defined in ...
FooImpl
is from a library, so it’s not a class I can modify. But I’m trying to simplify declaring the expect API, as there are several classes that have the same interface.
b
Seems not possible - essentially it would be duck typing in Kotlin.
j
That makes sense.