https://kotlinlang.org logo
s

SrSouza

01/13/2022, 12:38 AM
Hi folks, there is anyway to have
expect interface
with a
expect val property: String
that should be defined with
actual get() =
? The currently interface I want to move to multiplatform looks something like this:
Copy code
interface Screen : Serializable {
  val key: String
     get() = this::class.qualiedName ?: error()
}
So it was
Serializable
, I'm expect/actual for the JVM version to have Serializable (Android need it), and the key I'm not able to use expect/actual.
1
t

Trevor Stone

01/13/2022, 12:41 AM
Why not just have the interface as-is in common and then make platform specific Impl with the additional interfaces you need on the impl
s

SrSouza

01/13/2022, 12:42 AM
I found a solution, I'm not able to set the property as
expect
but it by default, and it also is
abstract
by default, so I add a
open
modifier and I was able to use
actual
on JVM
2 Views