File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change
1
+ // RUN: %target-typecheck-verify-swift
2
+
3
+ // https://github.com/apple/swift/issues/46000
4
+
5
+ import Dispatch
6
+ import Foundation
7
+
8
+ extension DispatchData {
9
+
10
+ func asFoundationData< T> ( execute: ( Data ) throws -> T ) rethrows -> T {
11
+
12
+ //FIXME: SWIFT(SR-3097) - DispatchData.withUnsafeBytes crashes when empty.
13
+ guard isEmpty == false else {
14
+ return try execute ( Data ( ) )
15
+ }
16
+
17
+ return try withUnsafeBytes { ( ptr: UnsafePointer < Int8 > ) -> Void in
18
+ // expected-error@-1 {{cannot convert return expression of type 'Void' to return type 'T'}}
19
+ let foundationData = Data ( bytesNoCopy: UnsafeMutableRawPointer ( mutating: ptr) , count: count, deallocator: . none)
20
+ return try execute ( foundationData) // expected-error {{cannot convert value of type 'T' to closure result type 'Void'}}
21
+ }
22
+ }
23
+ }
You can’t perform that action at this time.
0 commit comments