How can I write the same code in KN? I want to get...
# kotlin-native
a
How can I write the same code in KN? I want to get file name for function
func
Copy code
inline fun javaClassName(noinline func: () -> Unit) = func.javaClass.name
g
Not sure that it’s possible, there are no reflections on K/N
But I may be wrong in this particular case
a
No!
Copy code
func::class.qualifiedName
works. But result
null
when func out of kotlin class
g
Ah, nice
But it also makes sense for non kotlin classes
h
In my code i use
func.toString()
and filter the output a bit. Not the cleanest nor the fastest solution but works for me
I use it for a primitive Logging class that automagically prints information about the class/function that generated a message
I'm not too sure how this solution handles global functions though. But IIRC i used the `toString()`method over
::class.qualifiedName
for exactly this reason
a
This works well in most cases. Thanks.