I'm currently working on a multi-platform module using kotlin. To do so, I rely on the expect
/actual
mechanism.
I declare a simple class in Common.kt
:
expect class Bar constructor(
name: String
)
I'd like to use the defined class in a common method (also present in Common.kt
):
fun hello(bar: Bar) {
print("Hello, my name is ${bar.name}")
}
The actual implementation is defined in Jvm.kt
:
actual data class Bar actual constructor(
val name: String
)
The problem is I got the following error inside my hello
function
Unresolved reference: name
What am I doing wrong?