<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=""><div class="">Hello!</div><div class=""><br class=""></div><div class="">Here is a class that uses all of this protocols: <a href="https://gist.github.com/rabbitinspace/a88410d778e5ac955ee88bdfede6e00b" class="">https://gist.github.com/rabbitinspace/a88410d778e5ac955ee88bdfede6e00b</a></div><div class="">Line 19</div><div class=""><br class=""></div><div class="">Latest Xcode gives me this log: <a href="https://gist.github.com/rabbitinspace/6cb5ebd536a81b0b1cc6b0fadbabbe77" class="">https://gist.github.com/rabbitinspace/6cb5ebd536a81b0b1cc6b0fadbabbe77</a></div><div class="">It’s a compiler crash, I think</div><div class=""><br class=""></div><div class="">While the latest dev swift snapshot produces a build error: <a href="https://gist.github.com/rabbitinspace/944a62efc18432baf781e368a1023b87" class="">https://gist.github.com/rabbitinspace/944a62efc18432baf781e368a1023b87</a></div><div class="">Shortly:</div><div class=""><div style="margin: 0px 0px 0px 12px; text-indent: -12px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>cannot invoke 'authenticationService' with an argument list of type '(for: Remote.Type)’</div><div style="margin: 0px 0px 0px 12px; text-indent: -12px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>expected an argument list of type '(for: Remote.Type)’</div></div><div style="margin: 0px 0px 0px 12px; text-indent: -12px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><br class=""></div><div style="margin: 0px 0px 0px 12px; text-indent: -12px; line-height: normal;" class=""><span style="text-indent: 0px;" class="">I can build it with the latest dev snapshot (Xcode still can't) if I will constraint generic types in AuthController class:</span></div><div style="margin: 0px 0px 0px 12px; text-indent: -12px; line-height: normal;" class=""><span style="text-indent: 0px;" class="">Can’t compile: </span></div><div style="margin: 0px 0px 0px 12px; text-indent: -12px; line-height: normal;" class=""><pre style="background-color:#2b2b2b;color:#a9b7c6;font-family:'Menlo';font-size:9,0pt;" class=""><span style="color:#cc7832;font-weight:bold;" class=""> final class </span><span style="color:#769aa5;" class="">AuthController</span><<span style="color:#769aa5;" class="">Remote</span><span style="color:#cc7832;" class="">: </span>App.<span style="color:#82a094;" class="">Remote</span><span style="color:#cc7832;" class="">, </span><span style="color:#769aa5;" class="">Builder</span><span style="color:#cc7832;" class="">: </span><span style="background-color:#344134;" class="">RemoteAuthenticationServiceBuilder</span>></pre><div class=""><br class=""></div><div class="">This is compiles successfully:</div><div class=""><pre style="background-color:#2b2b2b;color:#a9b7c6;font-family:'Menlo';font-size:9,0pt;" class=""><span style="color:#cc7832;font-weight:bold;" class=""> final class </span><span style="color:#769aa5;" class="">AuthController</span><<span style="color:#769aa5;" class="">Remote</span><span style="color:#cc7832;" class="">: </span>App.<span style="color:#82a094;" class="">Remote</span><span style="color:#cc7832;" class="">, </span><span style="color:#769aa5;" class="">Builder</span><span style="color:#cc7832;" class="">: </span><span style="color:#82a094;" class="">RemoteAuthenticationServiceBuilder</span>> <br class=""> <span style="color:#cc7832;font-weight:bold;" class="">where </span><span style="color:#769aa5;" class="">Builder</span>.Service.Remote == <span style="color:#769aa5;" class="">Remote </span></pre><div class=""><br class=""></div></div></div><div style="margin: 0px 0px 0px 12px; text-indent: -12px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><div style="margin: 0px 0px 0px 12px; line-height: normal;" class=""><br class=""></div></div><br class=""><div><blockquote type="cite" class=""><div class="">25 дек. 2016 г., в 23:50, Slava Pestov via swift-users <<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>> написал(а):</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="">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=""> class Remote {</div><div class=""> struct Credentials {} </div><div class=""> }</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> and let us know if it solves your problem?</div><div class=""><br class=""></div><div class="">Slava</div><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Dec 25, 2016, at 1:05 PM, Игорь Никитин via swift-users <<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>> 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>-> (<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><<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>>(<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) -> 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 <span style="font-family: Menlo;" class=""><span style="color: rgb(204, 120, 50); font-weight: bold;" class="">where </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=""><a href="https://lists.swift.org/mailman/listinfo/swift-users" class="">https://lists.swift.org/mailman/listinfo/swift-users</a><br class=""></div></blockquote></div><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=""></body></html>