<div dir="ltr">So having a little more of a think about this what should happen in this situation:<div><br></div><div><div>class A {</div><div> func method() {</div><div> print("A")</div><div> }</div><div>}</div><div><br></div><div>protocol P {</div><div> func method()</div><div>}</div><div><br></div><div>extension P {</div><div> func method() {</div><div> print("P")</div><div> }</div><div>}</div><div><br></div><div>class B: A, P {</div><div> override func method() {</div><div> super.method()</div><div> print("B")</div><div> }</div><div>}</div><div><br></div><div>B().method()</div></div><div><br></div><div>When 'super' is called by the method in class B, should it call the method in class A or the protocol extension in extension P? As it stands by using override it always looks to it's superclass and ignores what happens in the protocol extension. This says to me that the 'override' keyword isn't right for solving this issue and should be reserved for inheritance, and not for solving this issue with choosing the subclass implementation over the protocol extension implementation.</div><div><br></div><div>Dale</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Mar 14, 2017 at 11:39 AM, Dale Buckley <span dir="ltr"><<a href="mailto:dalebuckley86@gmail.com" target="_blank">dalebuckley86@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">So I did consider using the 'override' keyword, but it then raised the question as to what should happen when 'super' is called.<div><br></div><div>I agree that by adding 'override' it makes it more obvious that you are overriding an existing implementation of the method, regardless of if it's defined in the class you are inheriting from or from the protocol extension. But if you add 'override' you are explicitly saying you can call the super implementation.</div><div><br></div><div>So the question is what should happen here? Realistically you could expect calling 'super' would call the protocol extension implementation of the method, but I'm trying to think of the problems that could occur if its implemented in that way.</div><div><br></div><div>Any thoughts on this?</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>Dale</div></font></span></div>
</blockquote></div><br></div>