I have two classes, Foo
and Bar
.
class Foo
class Bar
With a normal method inside Bar
, I can get the name of that method using reflection, like so:
class Bar {
fun doThing1() {}
fun doThing2() {
println(::doThing1.name)
}
}
However, if I have a function inside Bar
that is an extension function on Foo
, that syntax no longer works:
class Foo
class Bar {
fun Foo.doFooThing() {}
fun doThing2() {
println(::doFooThing.name) // does not work, unresolved reference
println(Foo::doFooThing.name) // 'doFooThing' is a member and extension at the same time. References to such elements are not allowed.
}
}
Is there a way to get the name of my extension method via reflection?