Why it is not possible to expect only parts of a class in a multiplatform project?


#1

Well, why?


#2

I strongly believe it is possible. When I remember correctly I used to do this in my project.


#3
class Test {

    expect fun test(){  <-- "Modifier 'expect' is not applicable to 'member function'"

    }

}

#4

Try putting expect on the class declaration also: expect class Test. And the expected method must not have a body.


#5

the other way around!

expect class Test {

    fun test(){  <-- "Expected declaration must not have a body"

    }

}

#6

Now I see what you are trying to do. You are trying to put non-expected declarations into an expected class. My first understanding was that you want to put additional functions into the actual class.

Yeah, what you are trying to do might not be possible. The best thing to do is extracting an interface with default functions in it.