https://kotlinlang.org logo
#touchlab-tools
Title
# touchlab-tools
j

Jacob Rhoda

10/24/2023, 4:08 PM
I’m testing out SKIE on my codebase and have a question about generics. I use a Kotlin class with generic type parameters from my Swift code, along with a Kotlin enum class. Because of the Obj-C interop, these generic parameters must all conform to
AnyObject
. However, if I am using the enum then I can’t specify the Swift enum type, and instead must refer to the underlying bridged type, which is now prepended with
__
. Is there any easy way to mask this on the Swift side so that I can use the Swift type along with the Kotlin generic class?
f

Filip Dolník

10/24/2023, 5:29 PM
Unfortunately no - it’s a limitation of how Obj-C bridging + generics work in Swift. Using the underlying bridged type is the intended solution.
j

Jacob Rhoda

10/24/2023, 6:01 PM
Okay, that makes sense. I was able to figure out how to use the underlying bridge type and the call-site is not as bad as I thought it’d be.
2 Views