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