No, that much is clear, my question here is, WHY is withLock marking its closure as @Sendable, since it should be executed synchronously in the same actor context?
Your last point seems to support what I asked: It's marked as @Sendable because the state is NOT marked as Sendable. If the state was marked as Sendable, then the closure would not need to be @Sendable, because the Sendable conformance on the state would protect it. It seems to me that the correct solution here would have been to mark State as Sendable instead, but I assume this was not done because you might want to protect a type that did not have an explicit Sendable conformance yet, so instead this quite confusing @Sendable conformance was added to other parts of the API?
But also, if so, why would the variation of withLock() that is available when State is Void be marked as @Sendable? This conformance means that OSAllocatedUnfairLock can not conform to NSLocking, which it otherwise could, and since there is no state there should be no need for this unexpected @Sendable conformance, right?