robstoll
12/02/2023, 10:01 PMObject.getPrototypeOf(obj).constructor.metadata.interfaces
. Looks like interfaces
is no longer available in IR backend. Is there another way to work around the limited properties KClass provides in JS?Artem Kobzar
12/03/2023, 6:38 AM$metadata$
is our internal implementation detail. Please, don't use it! We change it a lot because we don't suppose that someone except the compiler uses the information. Also, we are considering removing such details for all declarations that don't use reflection.Edoardo Luppi
12/04/2023, 8:17 AMArtem Kobzar
12/04/2023, 9:09 AMclass Foo: SomeInterface
Will be generated the the code like this:
class Foo {
// constructor and methods
}
setMetadata(Foo, "Foo", [SomeInterface], ...)
Edoardo Luppi
12/04/2023, 9:11 AMEdoardo Luppi
12/04/2023, 12:09 PMKClass.isInstance
and I've seen it is actually using the mentioned metadata.
internal class SimpleKClassImpl<T : Any>(jClass: JsClass<T>) : KClassImpl<T>(jClass) {
override val simpleName: String? = jClass.asDynamic().`$metadata$`?.simpleName.unsafeCast<String?>()
override fun isInstance(value: Any?): Boolean {
return jsIsType(value, jClass)
}
}
Artem Kobzar
12/04/2023, 12:14 PMrobstoll
12/05/2023, 6:22 AMinterface Foo
val o = object: Foo{}
o::class // simpleName is undefined
I'll have to check if isInstance works correctly in that case (as far as I remember, I had to add a fix in LEGACY as well)Artem Kobzar
12/05/2023, 9:39 AMo
is an anonymous object. What name do you expect to have in this case?robstoll
12/05/2023, 12:23 PMsetMetada
along the line of setMetadata(o, "o$1" , [Foo], ...)
or at least the interface is missing. I can get $o1
via JsClass.name as far as I rememberArtem Kobzar
12/05/2023, 12:29 PMrobstoll
12/05/2023, 12:31 PM