Search code examples
reflectionkotlinkotlin-reflect

Check if function is extension


Given a KFunction how can I check if it's a extension function?

The only way I know is to check if function.extensionReceiverParameter returns null. Is there any other or a recommended way?


Solution

  • Currently, the only way to check this is to use: function.extensionReceiverParameter.

    If it returns null it's not an extension function. If it returns a non-null value that function is a extension function