Merge pull request #444 from ktopley-apple/ktopley-numericCast-for-dispatch-block-flags
Use numericCast() to get the correct type when creating a dispatch_bl…
diff --git a/src/swift/Block.swift b/src/swift/Block.swift
index f1c2f08..1849907 100644
--- a/src/swift/Block.swift
+++ b/src/swift/Block.swift
@@ -40,11 +40,7 @@
internal var _block: _DispatchBlock
public init(qos: DispatchQoS = .unspecified, flags: DispatchWorkItemFlags = [], block: @escaping @convention(block) () -> ()) {
-#if os(Windows) && arch(x86_64)
- let flags = dispatch_block_flags_t(UInt32(flags.rawValue))
-#else
- let flags = dispatch_block_flags_t(UInt(flags.rawValue))
-#endif
+ let flags: dispatch_block_flags_t = numericCast(flags.rawValue)
_block = dispatch_block_create_with_qos_class(flags,
qos.qosClass.rawValue.rawValue, Int32(qos.relativePriority), block)
}
@@ -52,11 +48,7 @@
// Used by DispatchQueue.synchronously<T> to provide a path through
// dispatch_block_t, as we know the lifetime of the block in question.
internal init(flags: DispatchWorkItemFlags = [], noescapeBlock: () -> ()) {
-#if os(Windows) && arch(x86_64)
- let flags = dispatch_block_flags_t(UInt32(flags.rawValue))
-#else
- let flags = dispatch_block_flags_t(UInt(flags.rawValue))
-#endif
+ let flags: dispatch_block_flags_t = numericCast(flags.rawValue)
_block = _swift_dispatch_block_create_noescape(flags, noescapeBlock)
}