actual interface A {
actual fun doSomething() { /*do sth. */ }
}
This code causes an error, because the expected function is abstract by default and the actual function has an implementation, which means that modality is different. Can I somehow define the expect function as non-abstract? Usually you would give a function of an interface a body to make it non-abstract. If you do that, the error at the actual declaration is gone, but expected declarations must not have bodies, so that's another error.
k
Kris Wong
11/20/2019, 7:46 PM
interfaces can't have implementations
Kris Wong
11/20/2019, 7:47 PM
is there a reason you want to use expect/actual on an interface?
a
Andreas Jost
11/20/2019, 7:56 PM
@Kris Wong "Interfaces in Kotlin can contain declarations of abstract methods, _as well as method implementations._" from https://kotlinlang.org/docs/reference/interfaces.html#interfaces
This feature is quite handy in my opinion.
In the expect/actual context I just found a kinda hacky solution using an extension function: