Is there any way to deal with inheritance when usi...
# kotlin-native
m
Is there any way to deal with inheritance when using K/N as a dynamic library? I was hopeful I’d be able to cast the pointers and access different attributes of different classes, but that doesn’t appear to be the case. A simple Kotlin setup I’m trying is
Copy code
abstract class Parent(val a: Int) {}

class Child(val b: Int, a: Int) : Parent(a) {}

fun make_thing(): Parent {
    return Child(1, 2);
}
and then in C, doing
Copy code
demo_kref_Parent parent = demo_symbols()->kotlin.root.make_thing();
demo_kref_Child* child_ptr = (demo_kref_Child*) parent.pinned;
demo_kref_Child child = *child_ptr;
int b = demo_symbols()->kotlin.root.Child.get_b(child);
but it’s segfaulting on the
get_b
call.
s
Try to create
demo_kref_Child
with
.pinned = parent.pinned
instead.
m
thanks!