Created
September 22, 2023 10:30
-
-
Save mattmassicotte/d0b2b4eddf7c0c2ca7bdf3d516bb5f86 to your computer and use it in GitHub Desktop.
Capturing a non-Sendable in a @sendable closure that produces no warning
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct NonSendable { | |
} | |
@available(*, unavailable) | |
extension NonSendable: Sendable { | |
} | |
actor MyActor { | |
let nonSendable: NonSendable | |
init(nonSendable: @Sendable () -> NonSendable) { | |
self.nonSendable = nonSendable() | |
} | |
} | |
let nonSendable = NonSendable() | |
// why don't I get a warning about capturing a non-sendable value here? | |
let actor = MyActor(nonSendable: { nonSendable }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment