Skip to content

Commit a9e4d44

Browse files
committed
Revert "Use numericCast() to get the correct type when creating a dispatch_block_flags_t."
This (partially) reverts commit b048490. Unfortunately, the numeric cast'ed value cannot be used to construct the dispatch_flags_t type. Trying to change to an explicit construction also fails. This repairs the Windows build for the time being. Use the `numericCast` for other targets.
1 parent ff3bf51 commit a9e4d44

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/swift/Block.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,23 @@ public class DispatchWorkItem {
4040
internal var _block: _DispatchBlock
4141

4242
public init(qos: DispatchQoS = .unspecified, flags: DispatchWorkItemFlags = [], block: @escaping @convention(block) () -> ()) {
43+
#if os(Windows) && (arch(arm64) || arch(x86_64))
44+
let flags = dispatch_block_flags_t(UInt32(flags.rawValue))
45+
#else
4346
let flags: dispatch_block_flags_t = numericCast(flags.rawValue)
47+
#endif
4448
_block = dispatch_block_create_with_qos_class(flags,
4549
qos.qosClass.rawValue.rawValue, Int32(qos.relativePriority), block)
4650
}
4751

4852
// Used by DispatchQueue.synchronously<T> to provide a path through
4953
// dispatch_block_t, as we know the lifetime of the block in question.
5054
internal init(flags: DispatchWorkItemFlags = [], noescapeBlock: () -> ()) {
55+
#if os(Windows) && (arch(arm64) || arch(x86_64))
56+
let flags = dispatch_block_flags_t(UInt32(flags.rawValue))
57+
#else
5158
let flags: dispatch_block_flags_t = numericCast(flags.rawValue)
59+
#endif
5260
_block = _swift_dispatch_block_create_noescape(flags, noescapeBlock)
5361
}
5462

0 commit comments

Comments
 (0)