I just filed SR-2246 about how `queue.async(flags: .barrier)` is completely 
broken, and I think the problem comes down to `dispatch_block_t` is being 
imported as `() -> ()` instead of as `@convention(block) () -> ()`, and 
therefore `__dispatch_async` has the type `(DispatchQueue, () -> Void) -> Void` 
instead of `(DispatchQueue, @convention(block) () -> Void) -> Void`.

The reason I'm sending this email is because I'd like to fix this, but I have 
no idea how. In Swift 2.x the SDK overlay had an explicit definition for 
`dispatch_block_t` instead of importing it from the C header, but with the new 
Dispatch API, it seems to be relying on the clang importer to get 
__dispatch_async and friends (though I'm not sure what causes the __ prefix 
since dispatch_async doesn't seem to have the relevant attribute). Swift 2.2 
had a typealias for dispatch_block_t, but Swift 3 marks dispatch_block_t as 
being unavailable (although again I don't know how since I don't see the 
relevant attribute in the macOS SDK), so presumably reintroducing a typealias 
isn't a good idea, if it even works at all.

-Kevin Ballard
_______________________________________________
swift-dev mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-dev

Reply via email to