1

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?

Mibac
  • 8,990
  • 5
  • 33
  • 57
  • 1
    I don't know for sure but i think it's the only way. Kotlin reflection library is awkward in many aspects. e.g. You have to test whether the type represented by a KClass has a constructor or not to know whether this is an interface or a class. It lacks some extension properties to make it easy to learn and use. – glee8e May 07 '17 at 01:23

1 Answers1

0

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

Mibac
  • 8,990
  • 5
  • 33
  • 57