Is there a way to annotate an Objective-C API with `sending`?

I was just doing some research on Obj-C/Concurrency interoperability. I cannot find anything in clang's documentation, but I was wondering if an annotation exists to add sending?

2 Likes

(Apologies, my brain for some reason read Matt's post as "Sendable", not "sending". It's too early in the afternoon, apparently.)

1 Like

No worries at all! I should have included a link to the clang docs right from the beginning.

https://clang.llvm.org/docs/AttributeReference.html#customizing-swift-import

1 Like

I thought I figured this out by using __attribute__((swift_attr("sending"))), but nope that does not work.

This should work. Are you sure that you are using the syntax correctly? Here is an example from the test that validates that this works:

1 Like

I think this was a combination of:

a) it actually being slightly hard to conclusively prove that sending was in effect on the Swift side because region-based isolation makes the compiler hard to trick
b) probably me making a mistake with the syntax
c) Not all concurrency annotations added to Objective-C are visible in the Swift translation · Issue #74629 · swiftlang/swift · GitHub