Skip to content

Commit b048490

Browse files
committed
Use numericCast() to get the correct type when creating a dispatch_block_flags_t.
rdar://problem/44957560
1 parent afa6cc3 commit b048490

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

src/swift/Block.swift

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,23 +40,15 @@ 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(x86_64)
44-
let flags = dispatch_block_flags_t(UInt32(flags.rawValue))
45-
#else
46-
let flags = dispatch_block_flags_t(UInt(flags.rawValue))
47-
#endif
43+
let flags: dispatch_block_flags_t = numericCast(flags.rawValue)
4844
_block = dispatch_block_create_with_qos_class(flags,
4945
qos.qosClass.rawValue.rawValue, Int32(qos.relativePriority), block)
5046
}
5147

5248
// Used by DispatchQueue.synchronously<T> to provide a path through
5349
// dispatch_block_t, as we know the lifetime of the block in question.
5450
internal init(flags: DispatchWorkItemFlags = [], noescapeBlock: () -> ()) {
55-
#if os(Windows) && arch(x86_64)
56-
let flags = dispatch_block_flags_t(UInt32(flags.rawValue))
57-
#else
58-
let flags = dispatch_block_flags_t(UInt(flags.rawValue))
59-
#endif
51+
let flags: dispatch_block_flags_t = numericCast(flags.rawValue)
6052
_block = _swift_dispatch_block_create_noescape(flags, noescapeBlock)
6153
}
6254

0 commit comments

Comments
 (0)