According to its documentation, UserDefaults is "is thread-safe, and you can use the same object in multiple threads or tasks simultaneously."
However, it's not marked Sendable. Is there a reason?
Obviously, I can mark it as @retroactive @unchecked Sendable, but I don't want to encourage this practice for other types, and I'm worried that I'm missing something.
Thanks. Looks like they explicitly opted out in swift-corelibs-foundation, too, if my memory of what the @available annotation there is doing is right.
Yes that's correct - the top-level UserDefaults class itself is thread-safe, but there is no guarantee that all subclasses must be thread safe and when we looked into this class we determined there were indeed subclasses in not-so-uncommon use that were not thread safe, so UserDefaults cannot be Sendable. However, I do think that it might be able to be ~Sendable rather than explicitly non-Sendable (effectively allowing you to declare your own subclass that is Sendable). I'll need to double check on why it's explicitly not Sendable rather than ~Sendable in the SCL-F code above