<html><head><style>body{font-family:Helvetica,Arial;font-size:13px}</style></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">So it seems like you would expect it to work as I thought it should. However, from reading the language reference&nbsp;</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">there is no mention of whether derived types are conforming types and there are no examples shown that demonstrate this either.</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><br></div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">Can someone who knows verify whether this is a bug, or an oversight or as designed?</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><br></div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">The workaround for me is to move everything in the base class which neuters the type system somewhat.</div> <br> <div id="bloop_sign_1457391911999411200" class="bloop_sign"><div style="font-family:helvetica,arial;font-size:13px">Mark</div></div> <br><p class="airmail_on">On March 7, 2016 at 3:53:37 PM, Howard Lovatt (<a href="mailto:howard.lovatt@gmail.com">howard.lovatt@gmail.com</a>) wrote:</p> <blockquote type="cite" class="clean_bq"><span><div><div></div><div>


<title></title>


Looks like a compiler bug to me.&nbsp;<br>
<br>
On Tuesday, 8 March 2016, Mark Anders via swift-evolution
&lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt;
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word">
<div>
<div style="margin:0px">Consider the following (you can paste it in
a Playground to see the error):</div>
<div style="margin:0px"><br></div>
<div>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:Menlo">
<span style="color:#bb2ca2">class</span> <span>Node { }</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:Menlo">
<span style="color:#bb2ca2">class</span> <span>Containable :</span>
<span style="color:#4f8187">Node</span><span>{}</span></p>
<p><br></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:Menlo">
<span style="color:#bb2ca2">protocol</span> <span>Refers
{</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:Menlo">
<span>&nbsp; &nbsp;</span> <span style="color:#bb2ca2">var</span>
<span>to :</span> <span style="color:#4f8187">Node</span>
<span>{</span><span style="color:#bb2ca2">get</span><span>}</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:Menlo">
<span>}</span></p>
<p><br></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:Menlo">
<span style="color:#bb2ca2">class</span> <span>Link :</span>
<span style="color:#4f8187">Refers</span> <span>{</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:Menlo">
<span>&nbsp; &nbsp;</span> <span style="color:#bb2ca2">var</span>
<span>to :</span> <span style="color:#4f8187">Node</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:Menlo">
<span>&nbsp; &nbsp;</span> <span style="color:#bb2ca2">init</span><span>(n :</span> <span style="color:#4f8187">Node</span><span>) {</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:Menlo">
<span>&nbsp; &nbsp; &nbsp; &nbsp;</span> <span style="color:#4f8187">to</span> <span>= n</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:Menlo">
<span>&nbsp; &nbsp; }</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:Menlo">
<span>}</span></p>
<p><br></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:Menlo">
<span style="color:#bb2ca2">class</span> <span>Contains :</span>
<span style="color:#4f8187">Refers</span> <span>{</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:Menlo;color:rgb(79,129,135)">
<span style="color:#000000">&nbsp; &nbsp;</span> <span style="color:#bb2ca2">var</span> <span style="color:#000000">to :</span>
<span>Containable</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:Menlo">
<span>&nbsp; &nbsp;</span> <span style="color:#bb2ca2">init</span><span>(c :</span> <span style="color:#4f8187">Containable</span><span>) {</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:Menlo">
<span>&nbsp; &nbsp; &nbsp; &nbsp;</span> <span style="color:#4f8187">to</span> <span>= c</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:Menlo">
<span>&nbsp; &nbsp; }</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:Menlo">
</p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:Menlo">
<span>}</span></p>
</div>
<div><span><br></span></div>
This currently does not work because it seems that to adopt a
protocol, the type of protocol var must match exactly.</div>
<div><br>
<div>It would be great if objects could be said to adopt a protocol
if the type of the var is the type or a derived type. &nbsp;</div>
<div>This would allow me to treat the structure in a type safe way
(i.e. only a Containable can have a Contains
relationship),&nbsp;</div>
<div>while me to have a set of Refers and iterate through each
Node.</div>
<div><br>
<div>Is there a reason why the type must match exactly?&nbsp; Or
could protocols be enhanced to to allow matching</div>
<div>derived types, similar to assignment and func parameter rules?
&nbsp;</div>
<div><br></div>
<div><br></div>
<div><span style="font-family:helvetica,arial">Mark</span></div>
</div>
</div>
</div>
</blockquote>
<br>
<br>
--<br>
-- Howard.<br>


</div></div></span></blockquote></body></html>