<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div><br><br>Sent from my iPad</div><div><br>On May 11, 2016, at 9:33 AM, Vladimir.S &lt;<a href="mailto:svabox@gmail.com">svabox@gmail.com</a>&gt; wrote:<br><br></div><blockquote type="cite"><div><span>On 11.05.2016 16:42, Matthew Johnson wrote:</span><br><blockquote type="cite"><span>With #Self (or Type as we're now calling it) they would not need to</span><br></blockquote><blockquote type="cite"><span>override those requirements because the ancestor that initially declared</span><br></blockquote><blockquote type="cite"><span>conformance provides an inherited implementation that remains valid for</span><br></blockquote><blockquote type="cite"><span>all of its descendants.</span><br></blockquote><span></span><br><span>OK.. I see your point, thank you. But probably we thinks differently about the #Self 'behavior' and how it should be treated in case of protocol conformance.</span><br><span></span><br><span>First of all, the initial proposal (which I base all my understanding on):</span><br><span>On 10.05.2016 16:15, Erica Sadun via swift-evolution wrote:</span><br><span>&gt;----------------------------------&lt;</span><br><span>To focus SE-0068 and narrow its scope, I removed the `#Self` part of the proposal. This offered compile-time substitution of the defining type for a related #Self literal:</span><br><span></span><br><span> &nbsp;&nbsp;&nbsp;A further static identifier, #Self expands to static type of the code it appears within, completing the ways code may want to refer to the type it is declared in.</span><br><span></span><br><span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#Self expands to the static type of the code it is declared within. In value types, this is always the same as Self. In reference types, it refers to the declaring type. #Self will offer a literal textual replacement just like #file, etc.</span><br><span>&gt;----------------------------------&lt;</span><br><span></span><br><span>So, again, we have protocol</span><br><span></span><br><span>protocol A {</span><br><span> &nbsp;func f()-&gt;#Self</span><br><span>}</span><br><span></span><br><span>What does it mean for me? : Each class C, conformed to protocol A, should have func f() that returns exactly this class.</span><br><span></span><br><span>so, let's have</span><br><span></span><br><span>class B: A {</span><br><span> &nbsp;func f()-&gt;B {} // conforms to protocol</span><br><span>// or could be written as(the same):</span><br><span>//func f()-&gt;#Self {} // conforms to protocol</span><br><span>}</span><br><span></span><br><span>class C: A {</span><br><span> &nbsp;func f()-&gt;C {} // conforms to protocol</span><br><span>}</span><br><span></span><br><span>class D: A {</span><br><span> &nbsp;func f()-&gt;D {} // conforms to protocol</span><br><span>}</span><br><span></span><br><span>and now, you want to conform some existed non-final class to A protocol:</span><br><span></span><br><span>class E {</span><br><span> &nbsp;func f()-&gt;E {} // just has such method</span><br><span>}</span><br><span></span><br><span>extension E: A {} // seems like OK at this step</span><br><span></span><br><span>after this, what's the state of some existed derived from E classes ?</span><br><span></span><br><span>class F: E {}</span><br><span>class G: F {}</span><br><span></span><br><span>You conformed the base class E to A protocol. This automatically *reuqire* that F &amp; G also conforms to A protocol. They *must* be `is A`.</span><br><span>But I insist, they does not conform to A protocol as I understand the #Self proposal.</span><br><span></span><br><span>F().f() *must*(because of protocol A) return instance of F, but F only has f()-&gt;C from base class</span><br><span></span><br><span>G().f() *must*(because of protocol A) return instance of G, but G only has f()-&gt;C from base class</span><br></div></blockquote><div><br></div><div>I think you meant E here, not C.</div><br><blockquote type="cite"><div><span></span><br><span>This is why I don't understand how #Self could help to achieve the target with NSURL conformance.</span><br><span>These are my points. Please point if I'm wrong somewhere.</span><br></div></blockquote><br><div>You are describing the behavior of Self, not #Self. &nbsp;</div><div><br></div><div><blockquote type="cite"><font color="#000000"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; &nbsp; &nbsp;#Self expands to the static type of the code it is declared within. In value types, this is always the same as Self. In reference types, it refers to the <b>declaring</b> type.</span></font></blockquote><br></div><div>For implementations of protocol requirements the declaring type is the type that declares conformance.</div><div><br></div><div>Self is covariant, #Self (or Type) is invariant. &nbsp;That is the difference.</div></body></html>