<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="">Now I’m not sure that it’s a compiler bug.</div><div class="">Maybe I not provide enough info of the type system or whatever else</div><div class=""><br class=""></div><div class="">Thanks for the help!</div><br class=""><div><blockquote type="cite" class=""><div class="">26 дек. 2016 г., в 22:49, 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=""><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" class=""><div class=""><br class="Apple-interchange-newline">On Dec 26, 2016, at 2:30 PM, Игорь Никитин <<a href="mailto:devnikor@icloud.com" class="">devnikor@icloud.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><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 class="" style="margin: 0px 0px 0px 12px; text-indent: -12px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="Apple-tab-span" style="white-space: pre;">        </span>cannot invoke 'authenticationService' with an argument list of type '(for: Remote.Type)’</div><div class="" style="margin: 0px 0px 0px 12px; text-indent: -12px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="Apple-tab-span" style="white-space: pre;">        </span>expected an argument list of type '(for: Remote.Type)’</div></div><div class="" style="margin: 0px 0px 0px 12px; text-indent: -12px; font-size: 11px; line-height: normal; font-family: Menlo;"><br class=""></div><div class="" style="margin: 0px 0px 0px 12px; text-indent: -12px; line-height: normal;"><span class="" style="text-indent: 0px;">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 class="" style="margin: 0px 0px 0px 12px; text-indent: -12px; line-height: normal;"><span class="" style="text-indent: 0px;">Can’t compile: </span></div><div class="" style="margin: 0px 0px 0px 12px; text-indent: -12px; line-height: normal;"><pre class="" style="background-color: rgb(43, 43, 43); color: rgb(169, 183, 198); font-family: Menlo;"><span class="" style="color: rgb(204, 120, 50); font-weight: bold;"> final class </span><span class="" style="color: rgb(118, 154, 165);">AuthController</span><<span class="" style="color: rgb(118, 154, 165);">Remote</span><span class="" style="color: rgb(204, 120, 50);">: </span>App.<span class="" style="color: rgb(130, 160, 148);">Remote</span><span class="" style="color: rgb(204, 120, 50);">, </span><span class="" style="color: rgb(118, 154, 165);">Builder</span><span class="" style="color: rgb(204, 120, 50);">: </span><span class="" style="background-color: rgb(52, 65, 52);">RemoteAuthenticationServiceBuilder</span>></pre><div class=""><br class=""></div><div class="">This is compiles successfully:</div><div class=""><pre class="" style="background-color: rgb(43, 43, 43); color: rgb(169, 183, 198); font-family: Menlo;"><span class="" style="color: rgb(204, 120, 50); font-weight: bold;"> final class </span><span class="" style="color: rgb(118, 154, 165);">AuthController</span><<span class="" style="color: rgb(118, 154, 165);">Remote</span><span class="" style="color: rgb(204, 120, 50);">: </span>App.<span class="" style="color: rgb(130, 160, 148);">Remote</span><span class="" style="color: rgb(204, 120, 50);">, </span><span class="" style="color: rgb(118, 154, 165);">Builder</span><span class="" style="color: rgb(204, 120, 50);">: </span><span class="" style="color: rgb(130, 160, 148);">RemoteAuthenticationServiceBuilder</span>> <br class=""> <span class="" style="color: rgb(204, 120, 50); font-weight: bold;">where </span><span class="" style="color: rgb(118, 154, 165);">Builder</span>.Service.Remote == <span class="" style="color: rgb(118, 154, 165);">Remote </span></pre><div class=""><br class=""></div></div></div></div></div></blockquote><div class=""><br class=""></div><div class="">It seems this is the correct fix — the compile error is obtuse, but it sounds like it’s talking about the two different types (both named ‘Remote’).</div><div class=""><br class=""></div><div class="">If you feel this behavior is in error, do you mind filing a JIRA bug?</div><div class=""><br class=""></div><div class="">Slava</div><br class=""><blockquote type="cite" class=""><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class="" style="margin: 0px 0px 0px 12px; text-indent: -12px; font-size: 11px; line-height: normal; font-family: Menlo;"><div class="" style="margin: 0px 0px 0px 12px; line-height: normal;"><br class=""></div></div><br class=""><div class=""><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=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">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<span class="Apple-converted-space"> </span><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=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Hello!<div class=""><br class=""></div><div class="">I have few protocols with associated types:</div><div class=""><pre class="" style="background-color: rgb(43, 43, 43); color: rgb(169, 183, 198); font-family: Menlo;"><pre class="" style="font-family: Menlo;"><span class="" style="color: rgb(204, 120, 50); font-weight: bold;">protocol </span><span class="" style="background-color: rgb(52, 65, 52);">Remote</span> {<br class=""> <span class="" style="color: rgb(204, 120, 50); font-weight: bold;">associatedtype </span>Credentials<span class="" style="color: rgb(204, 120, 50);">: </span><span class="" style="color: rgb(130, 160, 148);">RemoteCredentials<br class=""></span><span class="" style="color: rgb(130, 160, 148);"><br class=""></span><span class="" style="color: rgb(130, 160, 148);"> </span><span class="" style="color: rgb(204, 120, 50); font-weight: bold;">static var </span><span class="" style="color: rgb(196, 179, 163);">url</span><span class="" style="color: rgb(204, 120, 50);">: </span><span class="" style="color: rgb(181, 182, 227);">URI </span>{ <span class="" style="color: rgb(204, 120, 50); font-weight: bold;">get </span>}<br class=""> <span class="" style="color: rgb(204, 120, 50); font-weight: bold;">static var </span><span class="" style="color: rgb(196, 179, 163);">name</span><span class="" style="color: rgb(204, 120, 50);">: </span><span class="" style="color: rgb(181, 182, 227);">String </span>{ <span class="" style="color: rgb(204, 120, 50); font-weight: bold;">get </span>}<br class=""> <span class="" style="color: rgb(204, 120, 50); font-weight: bold;">static var </span><span class="" style="color: rgb(196, 179, 163);">credentials</span><span class="" style="color: rgb(204, 120, 50);">: </span>Credentials.Type { <span class="" style="color: rgb(204, 120, 50); font-weight: bold;">get </span>}<br class="">}</pre><pre class="" style="font-family: Menlo;"><span class="" style="color: rgb(204, 120, 50); font-weight: bold;">protocol </span><span class="" style="background-color: rgb(52, 65, 52);">RemoteAuthenticating</span> {<br class=""> <span class="" style="color: rgb(204, 120, 50); font-weight: bold;">associatedtype </span>Remote<span class="" style="color: rgb(204, 120, 50);">: </span>App.<span class="" style="color: rgb(130, 160, 148);">Remote<br class=""></span><span class="" style="color: rgb(128, 128, 128);"><br class=""></span><span class="" style="color: rgb(128, 128, 128);"> </span><span class="" style="color: rgb(204, 120, 50); font-weight: bold;">func </span><span class="" style="color: rgb(196, 179, 163);">authenticate</span>(<span class="" style="color: rgb(196, 179, 163);">with </span>credentials<span class="" style="color: rgb(204, 120, 50);">: </span>Remote.Credentials) <span class="" style="color: rgb(204, 120, 50); font-weight: bold;">throws </span>-> (<span class="" style="color: rgb(118, 154, 165);">RemoteUser</span><span class="" style="color: rgb(204, 120, 50);">, </span><span class="" style="color: rgb(130, 160, 148);">ResponseRepresentable</span>?)<br class="">}</pre><div class=""><pre class="" style="font-family: Menlo;"><span class="" style="color: rgb(204, 120, 50); font-weight: bold;">protocol </span><span class="" style="color: rgb(130, 160, 148);">RemoteAuthenticationServiceBuilder </span>{<br class=""> <span class="" style="color: rgb(204, 120, 50); font-weight: bold;">associatedtype </span>Service<span class="" style="color: rgb(204, 120, 50);">: </span><span class="" style="color: rgb(130, 160, 148);">RemoteAuthenticating<br class=""></span><span class="" style="color: rgb(130, 160, 148);"><br class=""></span><span class="" style="color: rgb(130, 160, 148);"> </span><span class="" style="color: rgb(128, 128, 128);">// </span><span class="" style="color: rgb(168, 192, 35); font-style: italic;">TODO: `Service.Remote` should be constrained to `Remote` but compiler crashes<br class=""></span><span class="" style="color: rgb(168, 192, 35); font-style: italic;"> </span><span class="" style="color: rgb(204, 120, 50); font-weight: bold;">func </span><span class="" style="color: rgb(196, 179, 163);">authenticationService</span><<span class="" style="color: rgb(118, 154, 165);">Remote</span><span class="" style="color: rgb(204, 120, 50);">: </span>App.<span class="" style="color: rgb(130, 160, 148);">Remote</span>>(<span class="" style="color: rgb(196, 179, 163);">for</span><span class="" style="color: rgb(204, 120, 50);">: </span><span class="" style="color: rgb(118, 154, 165);">Remote</span>.Type) -> Service? <span class="" style="color: rgb(128, 128, 128);">// where Service.Remote == Remote<br class=""></span>}</pre></div></pre></div><div class="">It works fine until I uncomment the last <span class="" style="font-family: Menlo;"><span class="" style="color: rgb(204, 120, 50); font-weight: bold;">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=""><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></blockquote></div><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">_______________________________________________</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">swift-users mailing list</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="mailto:swift-users@swift.org" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">swift-users@swift.org</a><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="https://lists.swift.org/mailman/listinfo/swift-users" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">https://lists.swift.org/mailman/listinfo/swift-users</a></div></blockquote></div><br class=""></body></html>