From 7ad3d9b997f8f8d4e18e4ee651bae79cf4e6ddf3 Mon Sep 17 00:00:00 2001 From: Kim Topley Date: Mon, 16 Jul 2018 10:51:56 -0700 Subject: [PATCH] Change the signature for DispatchData.enumerateBytes() to match that of Data.enumerateBytes() for Swift 4.2 and obsolete the old version. rdar://problem/40775762 --- src/swift/Data.swift | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/swift/Data.swift b/src/swift/Data.swift index cc85a0873..e78b8335f 100644 --- a/src/swift/Data.swift +++ b/src/swift/Data.swift @@ -117,8 +117,22 @@ public struct DispatchData : RandomAccessCollection { return try body(contentPtr) } + @available(swift 4.2) + public func enumerateBytes( + _ block: (_ buffer: UnsafeBufferPointer, _ byteIndex: Int, _ stop: inout Bool) -> Void) + { + enumerateBytesCommon(block) + } + + @available(swift, obsoleted: 4.2, renamed: "enumerateBytes(_:)") public func enumerateBytes( block: (_ buffer: UnsafeBufferPointer, _ byteIndex: Int, _ stop: inout Bool) -> Void) + { + enumerateBytesCommon(block) + } + + private func enumerateBytesCommon( + _ block: (_ buffer: UnsafeBufferPointer, _ byteIndex: Int, _ stop: inout Bool) -> Void) { // we know that capturing block in the closure being created/passed to dispatch_data_apply // does not cause block to escape because dispatch_data_apply does not allow its