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
is () -> Unit
05/23/2019, 3:46 PM
If you want "is a function" that's something like
x is Function0<*>
Return type and argument types aren't recoverable in general.
05/23/2019, 3:55 PM
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.
05/23/2019, 3:57 PM
check if you can use reified inline functions for whatever you’re doing. (there the type is accessible because it’s inlined)
05/23/2019, 4:45 PM
@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.