# \[reflect\] Extend API to get parents/owners

**URL:** <https://discuss.kotlinlang.org/t/reflect-extend-api-to-get-parents-owners/25270>\
**Category:** Libraries\
**Created:** [July 23, 2022, 1:59pm UTC](https://discuss.kotlinlang.org/t/reflect-extend-api-to-get-parents-owners/25270 "2022-07-23T13:59:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![broot](https://avatars.discourse-cdn.com/v4/letter/b/a88e57/32.png) [@broot](https://discuss.kotlinlang.org/u/broot)\
**Post date:** [July 23, 2022, 1:59pm UTC](https://discuss.kotlinlang.org/t/reflect-extend-api-to-get-parents-owners/25270/1 "2022-07-23T13:59:19Z")

</div>

Are there any plans to extend the reflection API with possibility to go from children to parents, e.g. from function to class/package?

I think the biggest limitation of the reflection right now is that `KFunction` and `KProperty` only provide information about their “contents”, but not their identity/location. For example, `MyClass::foo` doesn’t provide a way to get back the `MyClass` which seems strange to me. Similarly, we can’t get the package of a class (there’s only `qualifiedName`), we can’t get the outer class from a nested class, etc.

`KDeclarationContainer` seems like an initial attempt to start adding a generic parent\<-\>children API. By looking into `kotlin.jvm.internal` it seems we already have most of needed stuff, but they’re internal. We have `CallableReference.owner: KDeclarationContainer` (also subtypes: `FunctionReference` and `PropertyReference`), we have `KPackage` (actually, `KPackageImpl`), etc. Are there plans to make some of them public, at least for JVM?

edit:  
I understand that `KFunction`/`KProperty` are abstract and they don’t have to be members of a class/package. I rather think about exposing e.g. `KFunctionReference`, similar to current `FunctionReference`.
