Enum with no non-sendable properties


I have an enum with no non-sendable properties.

Should I explicitly conform to Sendable?

enum Status { case ready }

let s1 : Sendable = Status.ready //there is no warning and seems to conform implicitly.

I am confused about the documentation in Sendable | Apple Developer Documentation

Unless the enum is marked public (the default access level is internal), it should be Sendable automatically. You can mark it Sendable explicitly if that makes it clearer to you, or to get better errors in case you accidentally add a non-Sendable case in the future, but it isn't necessary.


Thanks @bbrk24

I have tested what you said and yes it works exactly like what you have stated.
The public enum Status in my swift package doesn't conform to Sendable implicitly.

I am confused why this happens though.


Why does the access level (public or internal) determine whether the enum implicitly conforms to Sendable or not?

public types can be used by other modules, while internal types generally can’t. If public types were implicitly sendable, a library author might not realize that the type is inferred as sendable, and inadvertently cause problems for library users when they add a non-sendable property down the line — when really they never intended for it to be sendable in the first place. On the other hand, for internal types, the only place that it could break is within the same codebase as the type itself, so there’s no chance of causing downstream problems without noticing.


@bbrk24 Thanks a lot for that clear explanation