Why calling method toString()
on function reference results in an error KotlinReflectionInternalError
fun main() {
fun foo(){}
::foo.toString()
}
output:
Exception in thread "main" kotlin.reflect.jvm.internal.KotlinReflectionInternalError: Function 'foo' (JVM signature: main$foo()V) not resolved in class kotlin.jvm.internal.Intrinsics$Kotlin: no members found
at kotlin.reflect.jvm.internal.KDeclarationContainerImpl.findFunctionDescriptor(KDeclarationContainerImpl.kt:131)
at kotlin.reflect.jvm.internal.KFunctionImpl$descriptor$2.invoke(KFunctionImpl.kt:56)
at kotlin.reflect.jvm.internal.KFunctionImpl$descriptor$2.invoke(KFunctionImpl.kt:55)
at kotlin.reflect.jvm.internal.ReflectProperties$LazySoftVal.invoke(ReflectProperties.java:93)
at kotlin.reflect.jvm.internal.ReflectProperties$Val.getValue(ReflectProperties.java:32)
at kotlin.reflect.jvm.internal.KFunctionImpl.getDescriptor(KFunctionImpl.kt:55)
at kotlin.reflect.jvm.internal.KFunctionImpl.toString(KFunctionImpl.kt:185)
at kotlin.jvm.internal.FunctionReference.toString(FunctionReference.java:130)
at MainKt.main(Main.kt:3)
at MainKt.main(Main.kt)
kotlin-reflect
is available. – Credent