mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
The implementation of `withoutActuallyEscaping` for `@convention(block)` functions cannot verify at runtime that the function did not actually escape. Diagnose this as unsafe code under strict memory safety checking. Fixes rdar://139994149.
20 lines
638 B
Swift
20 lines
638 B
Swift
// RUN: %target-typecheck-verify-swift -strict-memory-safety
|
|
|
|
// REQUIRES: objc_interop
|
|
|
|
func callMe(body: @escaping @convention(block) () -> Void) { }
|
|
|
|
func callMeSwiftly(body: @escaping () -> Void) { }
|
|
|
|
func testCall(body: @convention(block) () -> Void, swiftBody: () -> Void) {
|
|
// expected-warning@+2{{unsafe}}{{3-3=unsafe }}
|
|
// expected-note@+1{{'withoutActuallyEscaping' function of type '@convention(block) () -> Void' is unsafe}}
|
|
withoutActuallyEscaping(body) { nonescapingBody in
|
|
callMe(body: nonescapingBody)
|
|
}
|
|
|
|
withoutActuallyEscaping(swiftBody) { nonescapingBody in
|
|
callMeSwiftly(body: nonescapingBody)
|
|
}
|
|
}
|