https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
m

mboudraa

02/21/2020, 3:21 PM
Good morning multiplatform trailblazers!!! I have a very noob question but i get mixed signals from the Internet. I can read here and there it’s possible to have access to generics from swift code by activating the
Xobjc-generics
flag on the compiler. That being said i keep having my type erased on the swift side and have to deal with a
Any?
instead. The type im trying to use is the
Result
type. Do you have any idea if it’s possible? Do I have to write my own
Either
type?
r

ribesg

02/21/2020, 3:25 PM
Kotlin generics and Objective-C generics aren’t completely compatible, so only a subset of what you can do in Kotlin can be converted to Objective-C. Swift is a little closer to Kotlin while still not 1-1, but in K/N we’re doing ObjC, not Swift anyway
r

russhwolf

02/21/2020, 3:26 PM
Some notes on the implementation and what is and isn't possible here: https://medium.com/@kpgalligan/kotlin-native-interop-generics-15eda6f6050f
In short, there still are a bunch of scenarios where you might need to cast because all three languages handle generics differently
m

mboudraa

02/21/2020, 3:50 PM
Thanks. Was very helpful