-
Notifications
You must be signed in to change notification settings - Fork 566
Unit bridges to KotlinUnit in Swift escaping closures #2549
Comments
Actually, this might be a bug? According to the interop doc, unit should bridge to void: https://kotlinlang.org/docs/reference/native/objc_interop.html |
This is still the case in K/N 1.3.21, would be great if one could just return Void in Swift instead of the unnecessary KotlinUnit currently. |
Unfortunately, the function types section specifically mentions that function types are treated different than regular functions and seems intentional. We are developing a library and the fact that we have to leak to users of our library that we are using Kotlin under the hood is not very nice. Not to speak of the fact that people are forced to type |
It is indeed a hard sell to iOS developers in my company and might not be taken seriously just because it adds noise. |
Improved with #2968. Will likely be shipped within 1.3.40. |
For functions/closures that return
KotlinUnit
in Swift, you get a warning about an unused result, which isn't ideal.In kotlin, this return type is used as
Void
in Swift (void
in C/Obj-C). I'm having trouble locating such an attribute, but ideally there'd be a way to attribute this return value in the Obj-C header as discardable (i.e. the@discardableResult
Obj-C equivalent). If there are other ways to improve this situation, those would also be nice. Thanks!The text was updated successfully, but these errors were encountered: