Does anyone understand how kotlin native (specific...
# kotlin-native
m
Does anyone understand how kotlin native (specifically the new memory model) works in relation to swift Sendable protocol? In xcode I've got some warnings about passing non-sendable types around - these are both some simple data types which should be relatively easy to handle just by adding conformance via an extension (I hope, e.g.
*extension* KotlinThrowable : *@unchecked* Sendable {}
), but there are also harder cases, like passing a coroutine Job to an onCancel completion handler, like so:
Copy code
var job: Kotlinx_coroutines_coreJob? = nil
    
    let onCancel = { job?.cancel(cause: nil) }
    
    return try await withTaskCancellationHandler(
        operation: {
            try await withCheckedThrowingContinuation({
                (continuation: CheckedContinuation<T?, Error>) in
                job = wrapper.subscribe(
                    onSuccess: { item in continuation.resume(returning: item) },
                    onThrow: { error in continuation.resume(throwing: SharedError(error)) }
                )
                
            })
        },
        onCancel: { onCancel() }
    )