dispatch_sync's block parameter should be @noescape for Swift

Originator:preble
Number:rdar://19770770 Date Originated:2/9/2015
Status:Closed Resolved:
Product:Xcode Product Version:6.3 (6D520o)
Classification: Reproducible:Always
 
Summary:
Because the block passed to dispatch_sync is executed during that function's lifetime, the block should be @noescape.

Steps to Reproduce:
Define a queue and a function like this:

let queue = dispatch_queue_create("Test Queue", DISPATCH_QUEUE_SERIAL)

func test(@noescape block: ()->()) {
    dispatch_sync(queue, block)
}

Observe compiler error: invalid use of non-escaping function in escaping context


Version:
Xcode 6.3 (6D520o), OS X 10.10.2 (14C109)

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!