Howdy! I'm trying to find an elegant workaround fo...
# getting-started
c
Howdy! I'm trying to find an elegant workaround for the
EXTENSION_IN_CLASS_REFERENCE_NOT_ALLOWED
diagnostic. I was hoping that I could declare an extension function as a member of a class, and then reference the function without using reflection. When using reflection, member extension functions show up as functions with the receiver as the first parameter right after the class instance parameter. I would expect this same behavior when references the extension function, but instead get the error
'XXX' is a member and an extension at the same time. References to such elements are not allowed
. Is there some intrinsic problem with supporting this use case, or should I submit a language change proposal?
Sample.kt.cpp
Here is the output when quickly printing the output of the reflected functions. You can see how close the second
sayHello
function is to the
samplePersonSayHello
function.