class Foo {}
fun Foo.bar() {}
fun main(args: Array<String>) {
check(Foo::class.memberExtensionFunctions.size > 0)
}
Why does the check fail? I would expect Foo.bar() to be in the memberExtensionFunctions list. I also tried declaredMemberExtensionFunction (though I’m not sure what the difference is) with the same result. Am I missing something?
Why does the check fail? I would expect Foo.bar() to be in the memberExtensionFunctions list.
I also tried declaredMemberExtensionFunction (though I’m not sure what the difference is) with the same result. Am I missing something?
The list contains member extension functions, i.e. those that are both members and extensions at the same time:
class C {
fun D.ext() {} // this is a member extension function
}
The task of finding all extension functions for Foo is equivalent to finding all methods which have Foo as the first parameter. Neither of these is possible without accessing every single class in your application through reflection.