<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 12 Mar 2017, at 08:21, Xiaodi Wu &lt;<a href="mailto:xiaodi.wu@gmail.com" class="">xiaodi.wu@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Sorry, I'm confused. The following works:<div class=""><br class=""></div><div class="">```</div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)" class="">protocol</span><span style="font-variant-ligatures:no-common-ligatures" class=""> Promise {</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo; color: rgb(186, 45, 162);" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp; </span><span style="font-variant-ligatures:no-common-ligatures" class="">associatedtype</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> Result</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">}</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo; min-height: 13px;" class=""><span style="font-variant-ligatures:no-common-ligatures" class=""></span><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)" class="">protocol</span><span style="font-variant-ligatures:no-common-ligatures" class=""> Scanner {</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">&nbsp; </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)" class="">associatedtype</span><span style="font-variant-ligatures:no-common-ligatures" class=""> ScannerPromise : Promise</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">&nbsp; </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)" class="">func</span><span style="font-variant-ligatures:no-common-ligatures" class=""> frobnicate&lt;T&gt;(</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)" class="">_</span><span style="font-variant-ligatures:no-common-ligatures" class="">: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(79,129,135)" class="">T</span><span style="font-variant-ligatures:no-common-ligatures" class="">) -&gt; ScannerPromise</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)" class="">where</span><span style="font-variant-ligatures:no-common-ligatures" class=""> ScannerPromise.Result == </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(79,129,135)" class="">T</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">}</span></div></div><div class="">```</div><div class=""><br class=""></div><div class="">Why does it matter if `ScannerPromise` is generic or not?</div><div class="gmail_extra"><br class=""></div></div></div></blockquote></div><br class=""><div class="">That’s some pretty strange syntax. I admit I didn’t even try that. ScannerPromise would necessarily have to be generic in this context, because I want to bind one of its associated types to a generic parameter from a function. There is no way a non-generic type could do that.</div><div class=""><br class=""></div><div class="">That said, even though the compiler accepts your code, it doesn’t seem to actually work:</div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><div class=""><font face="Courier" class="">protocol Promise {</font></div></div><div class=""><div class=""><font face="Courier" class="">&nbsp; associatedtype Result</font></div></div><div class=""><div class=""><font face="Courier" class="">&nbsp; func await() -&gt; Result</font></div></div><div class=""><div class=""><font face="Courier" class="">}</font></div></div><div class=""><div class=""><font face="Courier" class=""><br class=""></font></div></div><div class=""><div class=""><font face="Courier" class="">protocol Scanner {</font></div></div><div class=""><div class=""><font face="Courier" class="">&nbsp; associatedtype ScannerPromise : Promise</font></div></div><div class=""><div class=""><font face="Courier" class="">&nbsp; func frobnicate&lt;T&gt;(_: T) -&gt; ScannerPromise</font></div></div><div class=""><div class=""><font face="Courier" class="">&nbsp; &nbsp; where ScannerPromise.Result == T</font></div></div><div class=""><div class=""><font face="Courier" class="">}</font></div></div><div class=""><div class=""><font face="Courier" class=""><br class=""></font></div></div><div class=""><div class=""><font face="Courier" class="">func use&lt;S: Scanner, T&gt;(_ s: S, _ t: T) -&gt; T {</font></div></div><div class=""><div class=""><font face="Courier" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>return s.frobnicate(t).await()</font></div></div><div class=""><div class=""><font face="Courier" class="">}</font></div></div></blockquote><div class=""><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span> &nbsp; &nbsp;</div></div><div class=""><br class=""></div><div class="">3.0.2: Segfault</div><div class=""><br class=""></div><div class="">3.1:</div><div class=""><br class=""></div><div class="">error: repl.swift:13:14: error: cannot invoke 'frobnicate' with an argument list of type '(T)'<br class="">&nbsp; &nbsp;&nbsp;return s.frobnicate(t).await()<br class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;^<br class=""><br class="">repl.swift:13:14: note: expected an argument list of type '(T)'<br class="">&nbsp; &nbsp;&nbsp;return s.frobnicate(t).await()<br class=""></div><div class=""><br class=""></div><div class="">- Karl</div></body></html>