// RUN: %target-typecheck-verify-swift // https://github.com/apple/swift/issues/46000 struct DispatchData { let ptr: UnsafePointer func withUnsafeBytes(body: (UnsafePointer) throws -> Result) rethrows -> Result { try body(ptr as! UnsafePointer) } } struct Data {} extension DispatchData { func asFoundationData(execute: (Data) throws -> T) rethrows -> T { return try withUnsafeBytes { (ptr: UnsafePointer) -> Void in // expected-error@-1 {{cannot convert return expression of type 'Void' to return type 'T'}} let data = Data() return try execute(data) // expected-error {{cannot convert value of type 'T' to closure result type 'Void'}} } } }