Hello I have an inline function defined in kotlin ...
# multiplatform
n
Hello I have an inline function defined in kotlin and compiled to javascript using kotlin multiplatform. It appears as though that function doesn't get exported and so I cannot use it from javascript. Am I correct in making this deduction?
g
By default all Kotlin functions are mangled. You can use JsName annotation to expose this function
n
@gildor I realise they are mangled but it looks like for inline function they aren't exported, not even in mangled form. I did have the JsName annotation specified.
g
hm, interesting, they are exposed on JVM, maybe it’s different on JS, I don’t know actually. Is your inline function doesn’t have reified generics?
n
it does yes
g
This is the case
Inline function with reified generic cannot be exposed (same on jvm), if you need one on public API you have to wrap it to common function and pass class or any other generic information to invoke inline reified function not from Kotlin code
n
In the code I have written the inline function with reified generics appears to be exposed on jvm. I wrote a separate function that is only in the KotlinJS source code that doesn't use reified generics.
According to the bottom of this webpage inline functions can (and do) work : https://kotlinlang.org/docs/reference/inline-functions.html