Inheritance when compiled to native shared or static lib is not really working is it?
Lets assume a fairly simple class hierarchy:
Copy code
open class A {
fun testA() {println("Test A")}
}
class B: A {
fun testB() { println("Test B") }
}
Now we compile this to linux and class B has fun testB and is missing function testA.
Is that on purpose? Can i do something about it?
l
Landry Norris
06/15/2022, 4:09 PM
What are you using to see that testA is missing? To my knowledge, K/N doesn’t currently support C++ interop. If you’re just looking for symbols, K/N uses a C++ vtable under the hood last time I looked deep into the runtime (1.6.0). Since testA is final in class A, it should optimize it out and make sure when you call testA on an instance of B, it will call A_testA. I would imagine it would be the same if testA were open, but not overridden in B.
j
Julian Hille
06/15/2022, 5:48 PM
i tried to create a another cpp project using the shared/static lib and it was not able to compile and the structs in the header file were missing the testA
Julian Hille
06/15/2022, 5:59 PM
now looking at the temporary c code before compile there is also no testA
Julian Hille
06/15/2022, 6:06 PM
The func testA exists at the class testA and is wrapped in c as a function where i need to put in an instance of class
A
. Which obviously does not work when having an instance of struct
B
Julian Hille
06/15/2022, 6:15 PM
what i could do is add an override fun testA which does nothing besides calling super. that would / could / should work but should not be necessary