<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="">Sorry about the typo (filenames for the code were mentioned wrong).</div><div class=""><br class=""></div><div class="">The corrected filenames are as follows (<font color="#0433ff" class="">problem still occurs</font>):</div><div class=""><br class=""></div><div class=""><b class="">Question:</b></div><div class="">- Why does the error occur when <span class="" style="color: rgb(186, 45, 162); font-family: Menlo; font-size: 11px; background-color: rgb(255, 255, 255);">extension</span><span class="" style="font-family: Menlo; font-size: 11px; background-color: rgb(255, 255, 255);"> </span><span class="" style="font-family: Menlo; font-size: 11px; background-color: rgb(255, 255, 255); color: rgb(79, 129, 135);">CarID</span><span class="" style="font-family: Menlo; font-size: 11px; background-color: rgb(255, 255, 255);"> : </span><span class="" style="font-family: Menlo; font-size: 11px; background-color: rgb(255, 255, 255); color: rgb(79, 129, 135);">P2</span><span class="" style="font-family: Menlo; font-size: 11px; background-color: rgb(255, 255, 255);"> {} </span>is defined in <font color="#0433ff" class="">CarID.swift</font> ?</div><div class=""><br class=""></div><div class=""><div class=""><br class=""></div><div class=""><b class="" style="color: rgb(4, 51, 255);">CreateCars.swift:</b></div><div class=""><span class="" style="color: rgb(4, 51, 255);"><b class=""><br class=""></b></span></div><div class=""><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(186, 45, 162);">import</span> Foundation</div><div class="" style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(186, 45, 162); background-color: rgb(255, 255, 255);">protocol<span class="" style="color: rgb(0, 0, 0);"> P1 {</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(186, 45, 162); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);"> </span>associatedtype<span class="" style="color: rgb(0, 0, 0);"> ItemID</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">}</div><div class="" style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(186, 45, 162);">class</span> Car : <span class="" style="color: rgb(79, 129, 135);">P1</span> {</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);"> <span class="" style="color: rgb(186, 45, 162);">typealias</span> ItemID = <span class="" style="color: rgb(79, 129, 135);">CarID</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">}</div><div class="" style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);">//extension CarID : P2 {} //Error wouldn't occur if this line is uncommented and the line in CarID.swift is commented out</div><div class="" style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(186, 45, 162); background-color: rgb(255, 255, 255);">protocol<span class="" style="color: rgb(0, 0, 0);"> P2 {}</span></div><div class="" style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(186, 45, 162);">class</span> CreateItems<Something : <span class="" style="color: rgb(79, 129, 135);">P1</span>></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(79, 129, 135); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(186, 45, 162);">where</span><span class="" style="color: rgb(0, 0, 0);"> </span>Something<span class="" style="color: rgb(0, 0, 0);">.</span><span class="" style="color: rgb(112, 61, 170);">ItemID</span><span class="" style="color: rgb(0, 0, 0);"> : </span>P2<span class="" style="color: rgb(0, 0, 0);"> {}</span></div><div class="" style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(186, 45, 162);">class</span><span class="" style="color: rgb(0, 0, 0);"> CreateCars : </span><span class="" style="text-decoration: underline; color: rgb(79, 129, 135);">C</span><span class="" style="color: rgb(79, 129, 135);">reateItems</span><span class="" style="color: rgb(0, 0, 0);"><</span><span class="" style="color: rgb(79, 129, 135);">Car</span><span class="" style="color: rgb(0, 0, 0);">> {} </span>//Error: Type 'Car.ItemID' (aka 'CarID') does not conform to protocol 'P2'</div><div class="" style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(79, 129, 135); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(186, 45, 162);">extension</span><span class="" style="color: rgb(0, 0, 0);"> </span>CreateCars<span class="" style="color: rgb(0, 0, 0);"> {}</span></div><div class="" style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;"><br class=""></div></div><div class="" style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;"><br class=""></div><div class="" style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;"><span class="" style="color: rgb(4, 51, 255);"><b class=""><br class=""></b></span></div><div class="" style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;"><b class="" style="color: rgb(4, 51, 255);">CarID.swift:</b></div><div class="" style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;"><br class=""></div><div class="" style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;"><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="color: rgb(186, 45, 162);">import</span> Foundation</div><div class="" style="margin: 0px; line-height: normal; min-height: 14px;"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="color: rgb(186, 45, 162);">class</span> CarID {}</div><div class="" style="margin: 0px; line-height: normal; min-height: 14px;"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);"><span class="" style="color: rgb(186, 45, 162);">extension</span><span class="" style="color: rgb(0, 0, 0);"> </span><span class="" style="color: rgb(79, 129, 135);">CarID</span><span class="" style="color: rgb(0, 0, 0);"> : </span><span class="" style="color: rgb(79, 129, 135);">P2</span><span class="" style="color: rgb(0, 0, 0);"> {} </span>//If this line is moved to CreateCars.swift the error vanishes away</div></div><div class="" style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;"><br class=""></div><div class="" style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;"><br class=""></div><div class="" style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;">Thanks and regards,</div><div class="" style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;">Muthu</div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">On 17 Sep 2017, at 10:55 AM, somu subscribe 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="">Hi,<div class=""><br class=""></div><div class="">When using Generics with Protocols I get a compilation error depending on whether or not conformance to a protocol is defined in the same file or not.</div><div class=""><br class=""></div><div class=""><b class="">Error</b>: </div><div class=""><font face="Menlo" color="#5c0700" class="">Type 'Car.ItemID' (aka 'CarID') does not conform to protocol 'P2'</font></div><div class=""><br class=""></div><div class=""><div class="">I have 2 swift files:</div><div class="">- <font color="#0433ff" class="">CarID.swift</font></div><div class="">- <font color="#0433ff" class="">CreateCars.swift</font></div></div><div class=""><br class=""></div><div class=""><b class="">Observations:</b></div><div class="">- I get the error when <span style="color: rgb(186, 45, 162); font-family: Menlo; font-size: 11px; background-color: rgb(255, 255, 255);" class="">extension</span><span style="font-family: Menlo; font-size: 11px; background-color: rgb(255, 255, 255);" class=""> </span><span style="font-family: Menlo; font-size: 11px; background-color: rgb(255, 255, 255); color: rgb(79, 129, 135);" class="">CarID</span><span style="font-family: Menlo; font-size: 11px; background-color: rgb(255, 255, 255);" class=""> : </span><span style="font-family: Menlo; font-size: 11px; background-color: rgb(255, 255, 255); color: rgb(79, 129, 135);" class="">P2</span><span style="font-family: Menlo; font-size: 11px; background-color: rgb(255, 255, 255);" class=""> {} </span>is defined in <font color="#0433ff" class="">CarID.swift</font></div><div class="">-<font color="#0433ff" class=""> </font>I don’t get the error when<font color="#0433ff" class=""> </font><span style="color: rgb(186, 45, 162); font-family: Menlo; font-size: 11px; background-color: rgb(255, 255, 255);" class="">extension</span><span style="font-family: Menlo; font-size: 11px; background-color: rgb(255, 255, 255);" class=""> </span><span style="font-family: Menlo; font-size: 11px; background-color: rgb(255, 255, 255); color: rgb(79, 129, 135);" class="">CarID</span><span style="font-family: Menlo; font-size: 11px; background-color: rgb(255, 255, 255);" class=""> : </span><span style="font-family: Menlo; font-size: 11px; background-color: rgb(255, 255, 255); color: rgb(79, 129, 135);" class="">P2</span><font class=""><span style="font-family: Menlo; background-color: rgb(255, 255, 255); font-size: 11px;" class=""> {} </span>is defined in <font color="#0433ff" class="">CreateCars.swift</font> as shown in the comments below.</font></div><div class=""><font class=""><br class=""></font></div><div class=""><font class=""><b class="">Tested On:</b></font></div><div class=""><font class="">- <font color="#0433ff" class="">Xcode 9.0 (9A235) - GM</font></font></div><div class=""><font class="">- <font color="#0433ff" class="">Command Line project / iOS project</font></font></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><span style="color: rgb(4, 51, 255);" class=""><b class="">CarID.swift:</b></span></div><div class=""><span style="color: rgb(4, 51, 255);" class=""><b class=""><br class=""></b></span></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="color: #ba2da2" class="">import</span> Foundation</div><div style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(186, 45, 162); background-color: rgb(255, 255, 255);" class="">protocol<span style="" class=""> P1 {</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(186, 45, 162); background-color: rgb(255, 255, 255);" class=""><span style="" class=""> </span>associatedtype<span style="" class=""> ItemID</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">}</div><div style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="color: #ba2da2" class="">class</span> Car : <span style="color: #4f8187" class="">P1</span> {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""> <span style="color: #ba2da2" class="">typealias</span> ItemID = <span style="color: #4f8187" class="">CarID</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">}</div><div style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);" class="">//extension CarID : P2 {} //Error wouldn't occur if this line is uncommented and the line in CarID.swift is commented out</div><div style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(186, 45, 162); background-color: rgb(255, 255, 255);" class="">protocol<span style="" class=""> P2 {}</span></div><div style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="color: #ba2da2" class="">class</span> CreateItems<Something : <span style="color: #4f8187" class="">P1</span>></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(79, 129, 135); background-color: rgb(255, 255, 255);" class=""><span style="color: #ba2da2" class="">where</span><span style="" class=""> </span>Something<span style="" class="">.</span><span style="color: #703daa" class="">ItemID</span><span style="" class=""> : </span>P2<span style="" class=""> {}</span></div><div style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);" class=""><span style="color: #ba2da2" class="">class</span><span style="" class=""> CreateCars : </span><span style="text-decoration: underline ; color: #4f8187" class="">C</span><span style="color: #4f8187" class="">reateItems</span><span style="" class=""><</span><span style="color: #4f8187" class="">Car</span><span style="" class="">> {} </span>//Error: Type 'Car.ItemID' (aka 'CarID') does not conform to protocol 'P2'</div><div style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(79, 129, 135); background-color: rgb(255, 255, 255);" class=""><span style="color: #ba2da2" class="">extension</span><span style="" class=""> </span>CreateCars<span style="" class=""> {}</span></div><div style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;" class=""><br class=""></div></div><div style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;" class=""><span style="color: rgb(4, 51, 255);" class=""><b class=""><br class=""></b></span></div><div style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;" class=""><span style="color: rgb(4, 51, 255);" class=""><b class="">CreateCars.swift:</b></span></div><div style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;" class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="color: #ba2da2" class="">import</span> Foundation</div><div style="margin: 0px; line-height: normal; min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="color: #ba2da2" class="">class</span> CarID {}</div><div style="margin: 0px; line-height: normal; min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><span style="color: #ba2da2" class="">extension</span><span style="" class=""> </span><span style="color: #4f8187" class="">CarID</span><span style="" class=""> : </span><span style="color: #4f8187" class="">P2</span><span style="" class=""> {} </span>//If this line is moved to CreateCars.swift the error vanishes away</div></div><div style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;" class="">Thanks and regards,</div><div style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;" class="">Muthu</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>