is it expected that when i have a function with ge...
# kotlin-native
m
is it expected that when i have a function with generics (e.g.
fun <T> doSomething(list: List<T>): T
), this function is left out of a generated dynamic library entirely?
b
It might vary by platform. I think in Obj-C/Swift, you get a function that returns
id/Any
, but there's working being done to fix it for Obj-C/Swift: https://github.com/JetBrains/kotlin-native/pull/2850
Of the interops, generics interop has the roughest edges so far
m
yeah. if i remove the generic and make it
fun doSomething(list: List<Any>): Any
it works just fine
but with generics it just leaves the function out entirely
b
which platform?
m
mac osx
b
oh a plain/global function?
m
yes
b
For those, it should generate a class called <FileName>Kt
and then it'll be a class/static member
possible you found a bug though
m
yeah it seems like it should warn, at least
the generated native
.kexe
can use this function and works fine, it’s just missing from the dynamic library headers
b
Interesting! Recommend filing an issue on jetbrains/kotlin-native
👍 1
m
though i am using k/n
1.3.11
. i’ll try to upgrade first and see if it fixes
👍 1
no, this still happens on
1.3.30
. filing an issue
🙌 1
k
I’m not sure if I’m doing anything different, but I get this in the header
__attribute__((objc_subclassing_restricted)) __attribute__((swift_name(“FunctionsKt”))) @interface MainFunctionsKt : KotlinBase + (id _Nullable)getItemFromListIndex:(int32_t)index list:(NSArray<id> *)list __attribute__((swift_name(“getItemFromList(indexlist)“))); @end;
Built with 1.3.30, that function comes from a file called “Functions.kt”
To be clear, even with the generics support from the PR above, function generics don’t translate to Objc. However, I can get the function above to output, so this has to be some kind of config issue, or something weird (like maybe files named main.kt act differently, etc)
I’m rereading this now. This is not for Objc, but for C, yes?
👌 1
With plain C, I don’t know why, but can confirm those functions are not output. For Objc, they are stripped of generics
m
yeah, this is just for C static/dynamic libraries
and i wouldn’t be surprised if they’re left out or mishandled, since generics are hard, but i think it should at least warn