It seems every reference in Kotlin either extends ...
# announcements
p
It seems every reference in Kotlin either extends Any, or implements kotlin.Function. if there is a generic field is there any way to get the type of the function so it can be executed? Appears type data is erased and impossible to do anything like
Copy code
is () -> Unit
k
If you want "is a function" that's something like
x is Function0<*>
Return type and argument types aren't recoverable in general.
r
Generics are indeed erased. It's an intentional decision, not a bug. If you need information about specific types, you'll need to pass along the appropriate class instance.
s
check if you can use reified inline functions for whatever you’re doing. (there the type is accessible because it’s inlined)
p
@karelpeeters This is a multiplatform environment. Function0<> is a JVM class
does not appear to be possible with out passing some other data, even with using reified @Stephan Schroeder It is possible to cast to a function type though. There are other ways of doing what I want to do, just want to really understand what kotlin is doing and limitations.