Jan Skrasek
10/11/2023, 8:45 AMCannot convert value of type 'Int?' to expected argument type 'KotlinInt?'Am I doing something wrong?
public init(searchSessionId: String, approximateTierMarketing: Int32, tierMarketing: KotlinInt?, screen: allshared.SearchScreen)
- (instancetype)initWithSearchSessionId:(NSString *)searchSessionId approximateTierMarketing:(int32_t)approximateTierMarketing tierMarketing:(AllsharedInt * _Nullable)tierMarketing screen:(AllsharedSearchScreen *)screen __attribute__((swift_name("init(searchSessionId:approximateTierMarketing:tierMarketing:screen:)"))) __attribute__((objc_designated_initializer));
Filip Dolník
10/11/2023, 8:54 AMJan Skrasek
10/11/2023, 8:54 AM@Serializable
@ObjCName("GeneralCloseClickedEvent")
public data class CloseClickedEvent(
public val searchSessionId: String,
public val approximateTierMarketing: Int,
public val tierMarketing: Int?,
public val screen: Screen,
)
Filip Dolník
10/11/2023, 8:59 AMJan Skrasek
10/11/2023, 9:00 AMCannot convert value of type 'Int' to expected argument type 'Int32'
Int32(expresison)
makes it ok.Filip Dolník
10/11/2023, 9:04 AMInt
is exported as Int32
because in Kotlin Int
is 32 bit whereas Int
in Swift is either 32 or 64 bit depending on the platform (nowadays basically all platforms are 64 bit)
Unfortunately, you will need to make these conversions manuallyJan Skrasek
10/11/2023, 9:08 AMFilip Dolník
10/11/2023, 9:22 AMI had the feeling it worked before applying skie, I’m sorry.No problem, and just to be sure verify that. It’s not impossible that there is some bug (the type conversion algorithm is very complex)
Basically it means that our Kotlin code should prioritize using Longs to get implicit conversion from Swift’s Int (I hope it will work that way then).I’m not sure that would help. Those would be converted to Int64 so it would deal with the overflow issue. But you would still need to convert Int to Int64 - unless Swift does the conversion automatically if you target only 64 bit platforms (which I’m not sure it does, but maybe) But more importantly, you would shift the problem to the Kotlin codebase because some very important library functions work with integers instead of longs (for example lists).
Ad the nullability: so this is something Skie cannot workaround?To some extend yes, it’s one of the features that we have considered for a while now, but it’s possible only in certain cases. Unfortunately basically any feature in SKIE takes a significant amount of time so we have to carefully pick on what we want to work on. So I don’t know when if ever we get to that.
Is it at least solvable if KMP interops with Swift directly?It’s difficult to answer that because there is no public proposal for the Swift Interop yet and there are multiple options how it can be implemented - all with different tradeoffs. It should be possible to get rid of the KotlinInt class. However, it’s not possible to fully solve the Int vs Int64 problem. That’s a fundamental difference between Kotlin and Swift and those will be a problem even with the new interop (and there are unfortunately quite a lot of them).
Jan Skrasek
10/11/2023, 9:41 AM