I've been experimenting with interop code. I had a...
# kotlin-native
j
I've been experimenting with interop code. I had an idea to hook into a runtime library function in order to translate Kotlin lists to ObjC. I bumped into an odd compiler exception along the way and I'm curious why this doesn't work. I poked around the Konan compiler code, but I don't have much context here. Here's my code:
Copy code
@SymbolName("Kotlin_Interop_CreateNSArrayFromKList")
private external fun MyCreateNSArrayFromKList(list: List<*>) : NSArray

@SymbolName("Kotlin_Interop_createStablePointer")
private external fun MyCreateStablePointer(any: Any): COpaquePointer
Both of these functions are defined in the K/N runtime. When I compile, the first one produces this exception:
exception: java.lang.IllegalArgumentException: function Kotlin_Interop_CreateNSArrayFromKList already exists
@ ContextUtils.kt:276 The second one, which is also defined in the runtime, produces no exception. How does SymbolName work? I'm assuming it gives the compiler knowledge of the 'extern C' symbol that it should use for linking, not necessarily a declaration of a new function. The second example proves this hypothesis. So why does the compiler complain about the first function symbol name existing?