Foundation Date type not Sendable

Running this snippet in a playground on the Xcode 13.3 beta warns for passing a Date across actors:

@MainActor
class MainClass {
    func run1(date: Date) async throws {
        print("DATE \(date)")
    }
}

let playgroundTask = Task {
    let mc = await MainClass()

    // Warns: "Cannot pass argument of non-sendable type 'Date' across actors"
    try await mc.run1(date: Date.now)
}

Given that Date is a struct with only one property of type TimeInterval (Double) I was surprised that it isn't automatically marked as Sendable.

Is my thinking wrong around this?

Thanks!

I can't find the exact post (or maybe even a tweet), but IIRC the gist was that the first beta of Xcode 13.3 is too noisy with concurrency-related warnings. Not all types have required attributes applied to them, which I think is something to be expected from a beta release. This is going to be fixed in future versions.

Thanks Max! So we can probably expect Date to eventually be marked Sendable? I'm trying to get ahead of the impending mountain of Sendable warnings in our codebase when Xcode 13.3 is released so this is useful information : )

IDK for sure, time will tell. Here is the tweet:

2 Likes