<div style="white-space:pre-wrap">That explanation is succinct and cogent. I can see the need for this proposed behavior. Having just played around with conforming classes to protocols, I think #Self is rather clear, but Type would be a little mystifying.<br><br></div><div class="gmail_quote"><div dir="ltr">On Wed, May 11, 2016 at 08:43 Matthew Johnson via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<br>
Sent from my iPad<br>
<br>
&gt; On May 11, 2016, at 1:22 AM, Vladimir.S &lt;<a href="mailto:svabox@gmail.com" target="_blank">svabox@gmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt; &gt; No, class would not need to be final to conform to a requirement returning #Self.  The difference is that with Self covaries and #Self does not.  This means you *do not need* to guarantee that all subclasses override a requirement that returns #Self, while you do need to guarantee that all subclasses override a requirement that returns Self.<br>
&gt;<br>
&gt; I&#39;m probably slow these day, but I(and probably someone else) just can&#39;t understand this. Thank you for your patience in explaining this:<br>
&gt; Just after you conforms *base* class to *any* protocol, any possible subclass *must* (you *have to* guarantee this) conform the same protocol.<br>
&gt;<br>
&gt; class A {..}<br>
&gt; class B:A {..}<br>
&gt; class C:A {..}<br>
&gt; protocol D {..}<br>
&gt; extension A: D {}<br>
&gt; -&gt; now B&amp;C and any other existed and *possible* subclass *must* conforms to the same protocol D just because of inheritance. As soon as they are subclass of A, they *must* be `is D` and *must* have the methods that return #Self. No?<br>
<br>
Yes, they must and will conform.  The distinction is that if the protocol has requirements returning Self all subclasses must override those requirements and to return their type because the inherited implementation returns their supertype.  With #Self (or Type as we&#39;re now calling it) they would not need to override those requirements because the ancestor that initially declared conformance provides an inherited implementation that remains valid for all of its descendants.<br>
<br>
&gt;<br>
&gt;&gt; On 10.05.2016 22:04, Matthew Johnson wrote:<br>
&gt;&gt;<br>
&gt;&gt;&gt; On May 10, 2016, at 1:38 PM, Vladimir.S &lt;<a href="mailto:svabox@gmail.com" target="_blank">svabox@gmail.com</a>&gt; wrote:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; On 10.05.2016 20:50, Matthew Johnson wrote:<br>
&gt;&gt;&gt;&gt; No, the whole point is that D.f() returns C because C is the requirement<br>
&gt;&gt;&gt;&gt; of &#39;f&#39; is declared to return #Self which is C where the protocol<br>
&gt;&gt;&gt;&gt; conformance is declared and implemented.  If you want a covariant<br>
&gt;&gt;&gt;&gt; requirement you would use Self as the return type, not #Self.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; I just followed your example with NSURL.. Probably I don&#39;t understand the point, but you said you want to conform a non-final class to protocol with method -&gt; #Self.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; ---------------------&lt;<br>
&gt;&gt;&gt; protocol A { static func createWithString(s: String) -&gt; Self }<br>
&gt;&gt;&gt; extension NSURL: A { // cannot conform because NSURL is non-final }<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; If we could define a protocol requirement that didn&#39;t covary (using<br>
&gt;&gt;&gt; #Self or whatever) we would be able to write the desired conformance.<br>
&gt;&gt;&gt;&gt; ---------------------&lt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; And I don&#39;t understand how do you want to achieve the target, as even if we &#39;invent&#39; #Self, this (as I understand) can&#39;t work as class is not final. Just like with &#39;simple&#39; Self - class must be final to conform. Thank you for clarification.<br>
&gt;&gt;<br>
&gt;&gt; No, class would not need to be final to conform to a requirement returning #Self.  The difference is that with Self covaries and #Self does not.  This means you do not need to guarantee that all subclasses override a requirement that returns #Self, while you do need to guarantee that all subclasses override a requirement that returns Self.<br>
&gt;&gt;<br>
&gt;&gt; The requirement to guarantee that all subclasses provide this override is the reason you cannot declare conformance in the case of requirements returning Self.  Since this isn’t necessary for #Self (will probably have a different name) the class does not need to be final in order to conform.<br>
&gt;&gt;<br>
&gt;&gt; -Matthew<br>
&gt;&gt;<br>
&gt;&gt; .<br>
&gt;&gt;<br>
<br>
_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</blockquote></div>