Julian Hille
06/16/2022, 12:46 PMopen class A {
fun testA() {
println("testA")
}
open fun test() {
println("aaa")
}
}
class B: A() {
fun testB() {
println("testA")
}
override fun test() {
println("bbb")
}
}
this leads to c code of:
struct {
lib_sdk_KType* (*_type)(void);
lib_sdk_kref_sdk_A (*A)();
void (*test)(lib_sdk_kref_sdk_A thiz);
void (*testA)(lib_sdk_kref_sdk_A thiz);
} A;
struct {
lib_sdk_KType* (*_type)(void);
lib_sdk_kref_sdk_B (*B)();
void (*test)(lib_sdk_kref_sdk_B thiz);
void (*testB)(lib_sdk_kref_sdk_B thiz);
} B;
and overriding testA with a super call:
open class A {
open fun testA() {
println("testA")
}
open fun test() {
println("aaa")
}
}
class B: A() {
fun testB() {
println("testA")
}
override fun test() {
println("bbb")
}
override fun testA() = super.testA()
}
leads to:
struct {
lib_sdk_KType* (*_type)(void);
lib_sdk_kref_sdk_A (*A)();
void (*test)(lib_sdk_kref_sdk_A thiz);
void (*testA)(lib_sdk_kref_sdk_A thiz);
} A;
struct {
lib_sdk_KType* (*_type)(void);
lib_sdk_kref_sdk_B (*B)();
void (*test)(lib_sdk_kref_sdk_B thiz);
void (*testA)(lib_sdk_kref_sdk_B thiz);
void (*testB)(lib_sdk_kref_sdk_B thiz);
} B;
is this on purpose?
should i really add overrides with a single super call to all the places?
should i cast a B instance to A and use struct A to call overriden testA func with the casted instance?
All of this feels unnecessary complexJulian Hille
06/16/2022, 2:12 PM