<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="">Hi Igor,<div class=""><br class=""></div><div class="">Your example is not self-contained, so I added the following definitions:</div><div class=""><br class=""></div><div class=""><div class="">struct URI {}</div><div class=""><br class=""></div><div class="">struct App {</div><div class="">&nbsp; class Remote {</div><div class="">&nbsp; &nbsp; struct Credentials {}&nbsp;</div><div class="">&nbsp; }</div><div class="">}</div><div class=""><br class=""></div><div class="">struct RemoteUser {}</div><div class=""><br class=""></div><div class="">protocol ResponseRepresentable {}</div><div class=""><br class=""></div><div class="">protocol RemoteCredentials {}</div></div><div class=""><br class=""></div><div class="">Unfortunately, this makes the code compile in both Swift 3.0 and the latest code built from GitHub, even with the ‘where’ part uncommented, so I suspect we’ll need a larger testcase to reproduce the original issue.</div><div class=""><br class=""></div><div class="">However from looking at the code, what you’re doing is adding a requirement to an associated type of the ‘Self’ generic parameter, which Swift 3.0 did not model properly, but it is one of the things we addressed in some recent refactoring work.</div><div class=""><br class=""></div><div class="">Could you try the latest development snapshot from <a href="http://swift.org" class="">swift.org</a>&nbsp;and let us know if it solves your problem?</div><div class=""><br class=""></div><div class="">Slava</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 25, 2016, at 1:05 PM, Игорь Никитин via swift-users &lt;<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hello!<div class=""><br class=""></div><div class="">I have few protocols with associated types:</div><div class=""><pre style="background-color:#2b2b2b;color:#a9b7c6;font-family:'Menlo';font-size:9,0pt;" class=""><pre style="font-family: Menlo;" class=""><span style="color:#cc7832;font-weight:bold;" class="">protocol </span><span style="background-color:#344134;" class="">Remote</span> {<br class="">    <span style="color:#cc7832;font-weight:bold;" class="">associatedtype </span>Credentials<span style="color:#cc7832;" class="">: </span><span style="color:#82a094;" class="">RemoteCredentials<br class=""></span><span style="color:#82a094;" class=""><br class=""></span><span style="color:#82a094;" class="">    </span><span style="color:#cc7832;font-weight:bold;" class="">static var </span><span style="color:#c4b3a3;" class="">url</span><span style="color:#cc7832;" class="">: </span><span style="color:#b5b6e3;" class="">URI </span>{ <span style="color:#cc7832;font-weight:bold;" class="">get </span>}<br class="">    <span style="color:#cc7832;font-weight:bold;" class="">static var </span><span style="color:#c4b3a3;" class="">name</span><span style="color:#cc7832;" class="">: </span><span style="color:#b5b6e3;" class="">String </span>{ <span style="color:#cc7832;font-weight:bold;" class="">get </span>}<br class="">    <span style="color:#cc7832;font-weight:bold;" class="">static var </span><span style="color:#c4b3a3;" class="">credentials</span><span style="color:#cc7832;" class="">: </span>Credentials.Type { <span style="color:#cc7832;font-weight:bold;" class="">get </span>}<br class="">}</pre><pre style="font-family: Menlo;" class=""><span style="color:#cc7832;font-weight:bold;" class="">protocol </span><span style="background-color:#344134;" class="">RemoteAuthenticating</span> {<br class="">    <span style="color:#cc7832;font-weight:bold;" class="">associatedtype </span>Remote<span style="color:#cc7832;" class="">: </span>App.<span style="color:#82a094;" class="">Remote<br class=""></span><span style="color:#808080;" class=""><br class=""></span><span style="color:#808080;" class="">    </span><span style="color:#cc7832;font-weight:bold;" class="">func </span><span style="color:#c4b3a3;" class="">authenticate</span>(<span style="color:#c4b3a3;" class="">with </span>credentials<span style="color:#cc7832;" class="">: </span>Remote.Credentials) <span style="color:#cc7832;font-weight:bold;" class="">throws </span>-&gt; (<span style="color:#769aa5;" class="">RemoteUser</span><span style="color:#cc7832;" class="">, </span><span style="color:#82a094;" class="">ResponseRepresentable</span>?)<br class="">}</pre><div class=""><pre style="font-family: Menlo;" class=""><span style="color: rgb(204, 120, 50); font-weight: bold;" class="">protocol </span><span style="color: rgb(130, 160, 148);" class="">RemoteAuthenticationServiceBuilder </span>{<br class="">    <span style="color: rgb(204, 120, 50); font-weight: bold;" class="">associatedtype </span>Service<span style="color: rgb(204, 120, 50);" class="">: </span><span style="color: rgb(130, 160, 148);" class="">RemoteAuthenticating<br class=""></span><span style="color: rgb(130, 160, 148);" class=""><br class=""></span><span style="color: rgb(130, 160, 148);" class="">    </span><span style="color: rgb(128, 128, 128);" class="">// </span><span style="color: rgb(168, 192, 35); font-style: italic;" class="">TODO: `Service.Remote` should be constrained to `Remote` but compiler crashes<br class=""></span><span style="color: rgb(168, 192, 35); font-style: italic;" class="">    </span><span style="color: rgb(204, 120, 50); font-weight: bold;" class="">func </span><span style="color: rgb(196, 179, 163);" class="">authenticationService</span>&lt;<span style="color: rgb(118, 154, 165);" class="">Remote</span><span style="color: rgb(204, 120, 50);" class="">: </span>App.<span style="color: rgb(130, 160, 148);" class="">Remote</span>&gt;(<span style="color: rgb(196, 179, 163);" class="">for</span><span style="color: rgb(204, 120, 50);" class="">: </span><span style="color: rgb(118, 154, 165);" class="">Remote</span>.Type) -&gt; Service? <span style="color: rgb(128, 128, 128);" class="">// where Service.Remote == Remote<br class=""></span>}</pre></div></pre></div><div class="">It works fine until I uncomment the last&nbsp;<span style="font-family: Menlo;" class=""><span style="color: rgb(204, 120, 50); font-weight: bold;" class="">where&nbsp;</span></span>statement</div><div class="">If I trying to constraint Service.Remote type compiler will crash with segfault 11</div><div class="">I can guess that it's a compiler bug, but maybe I’m using generics in wrong way?</div><div class=""><br class=""></div></div>_______________________________________________<br class="">swift-users mailing list<br class=""><a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-users<br class=""></div></blockquote></div><br class=""></div></body></html>