<div dir="ltr">Yeah I actually have a few of those myself that I can no longer do.</div><br><div class="gmail_quote"><div dir="ltr">On Wed, Sep 7, 2016 at 3:26 PM Jon Shier <<a href="mailto:jon@jonshier.com">jon@jonshier.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Perhaps relatedly, it no longer seems possible to mark typealiased closures as @escaping. That was quite handy when you know that closures will always be used asynchronously.<div><br></div><div><br></div><div>Jon</div><div><br></div><div><br><div><blockquote type="cite"></blockquote></div></div></div><div style="word-wrap:break-word"><div><div><blockquote type="cite"><div>On Sep 7, 2016, at 6:15 PM, Shawn Erickson via swift-users <<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a>> wrote:</div><br></blockquote></div></div></div><div style="word-wrap:break-word"><div><div><blockquote type="cite"><div><div dir="ltr">I should note that this issue also appeared in an earlier variant of Swift after the addition of @escaping but I was on vacation so didn't get a chance to report it then. It isn't new with the Xcode 8 GM.<br><br><div class="gmail_quote"><div dir="ltr">On Wed, Sep 7, 2016 at 3:08 PM Shawn Erickson <<a href="mailto:shawnce@gmail.com" target="_blank">shawnce@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I like and fully supported the change to @escaping away from @noescape however in a body of code that I am porting to the latest Swift 3 variant (as found in Xcode 8 GM) I am hitting an issue for methods that take an optional completion closure. If optional is involved I can't find a way to apply @escape to the escaping closure. See the following for an basic example...<div><br></div><div>Is their a way to do what I need and/or is this an edge case in the implementation of @escaping?<br><div><br></div><div><div><font face="monospace" size="1">typealias MyCallback = (String)->()</font></div><div><font face="monospace" size="1"><br></font></div><div><font face="monospace" size="1">// Happy</font></div><div><font face="monospace" size="1">func foo1(bar: String, completion: ((String)->())) {</font></div><div><font face="monospace" size="1"> completion(bar)</font></div><div><font face="monospace" size="1">}</font></div><div><font face="monospace" size="1"><br></font></div><div><font face="monospace" size="1">// Happy</font></div><div><font face="monospace" size="1">func foo2(bar: String, completion: MyCallback) {</font></div><div><font face="monospace" size="1"> completion(bar)</font></div><div><font face="monospace" size="1">}</font></div><div><font face="monospace" size="1"><br></font></div><div><font face="monospace" size="1">// Happy</font></div><div><font face="monospace" size="1">func foo3(bar: String, completion: ((String)->())? = nil) {</font></div><div><font face="monospace" size="1"> completion?(bar)</font></div><div><font face="monospace" size="1">}</font></div><div><font face="monospace" size="1"><br></font></div><div><font face="monospace" size="1">// Happy</font></div><div><font face="monospace" size="1">func foo4(bar: String, completion: MyCallback? = nil) {</font></div><div><font face="monospace" size="1"> completion?(bar)</font></div><div><font face="monospace" size="1">}</font></div><div><font face="monospace" size="1"><br></font></div><div><font face="monospace" size="1">// Happy</font></div><div><font face="monospace" size="1">func foo5(bar: String, completion: Optional<MyCallback> = nil) {</font></div><div><font face="monospace" size="1"> completion?(bar)</font></div><div><font face="monospace" size="1">}</font></div><div><font face="monospace" size="1"><br></font></div><div><font face="monospace" size="1">// Happy</font></div><div><font face="monospace" size="1">func foo6(bar: String, completion: @escaping (String)->()) {</font></div><div><font face="monospace" size="1"> completion(bar)</font></div><div><font face="monospace" size="1">}</font></div><div><font face="monospace" size="1"><br></font></div><div><font face="monospace" size="1">// Happy</font></div><div><font face="monospace" size="1">func foo7(bar: String, completion: @escaping MyCallback) {</font></div><div><font face="monospace" size="1"> completion(bar)</font></div><div><font face="monospace" size="1">}</font></div><div><font face="monospace" size="1"><br></font></div><div><font face="monospace" size="1">// Unhappy...</font></div><div><font face="monospace" size="1">// "@escaping attribute only applies to function types"</font></div><div><font face="monospace" size="1">func foo8(bar: String, completion: @escaping ((String)->())? = nil) {</font></div><div><font face="monospace" size="1"> completion?(bar)</font></div><div><font face="monospace" size="1">}</font></div><div><font face="monospace" size="1"><br></font></div><div><font face="monospace" size="1">// Unhappy...</font></div><div><font face="monospace" size="1">// "@escaping attribute only applies to function types"</font></div><div><font face="monospace" size="1">func foo9(bar: String, completion: @escaping MyCallback? = nil) {</font></div><div><font face="monospace" size="1"> completion?(bar)</font></div><div><font face="monospace" size="1">}</font></div><div><font face="monospace" size="1"><br></font></div><div><font face="monospace" size="1">// Unhappy...</font></div><div><font face="monospace" size="1">// "@escaping attribute only applies to function types"</font></div><div><font face="monospace" size="1">func foo10(bar: String, completion: (@escaping ((String)->()))? = nil) {</font></div><div><font face="monospace" size="1"> completion?(bar)</font></div><div><font face="monospace" size="1">}</font></div><div><font face="monospace" size="1"><br></font></div><div><font face="monospace" size="1">// Unhappy...</font></div><div><font face="monospace" size="1">// "@escaping attribute only applies to function types"</font></div><div><font face="monospace" size="1">func foo11(bar: String, completion: (@escaping MyCallback)? = nil) {</font></div><div><font face="monospace" size="1"> completion?(bar)</font></div><div><font face="monospace" size="1">}</font></div><div><font face="monospace" size="1"><br></font></div><div><font face="monospace" size="1">// Unhappy...</font></div><div><font face="monospace" size="1">// "@escaping attribute only applies to function types"</font></div><div><font face="monospace" size="1">func foo12(bar: String, completion: Optional<@escaping MyCallback> = nil) {</font></div><div><font face="monospace" size="1"> completion?(bar)</font></div><div><font face="monospace" size="1">}</font></div></div></div></div></blockquote></div></div></div></blockquote></div></div></div><div style="word-wrap:break-word"><div><div><blockquote type="cite"><div>
_______________________________________________<br>swift-users mailing list<br><a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a><br><a href="https://lists.swift.org/mailman/listinfo/swift-users" target="_blank">https://lists.swift.org/mailman/listinfo/swift-users</a><br></div></blockquote></div><br></div></div></blockquote></div>