<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="">When a class conforms to a protocol and a requirement is fulfilled by a method in an extension, the class does not get a vtable entry for the extension method. So it cannot be overridden in a subclass — there’s nothing to dynamically dispatch here. We plan on addressing this as part of ABI stability.</div><div class=""><br class=""></div><div class="">Slava</div><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">On Feb 22, 2017, at 9:39 AM, David Hart 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=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">In the following piece of code, can somebody explain the last result? Why the break in consistency? Is this a bug?<div class=""><br class=""></div><div class=""><font face="Menlo" class="">protocol P {<br class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>func foo() -> String<br class="">}<br class=""><br class="">extension P {<br class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>func foo() -> String { return "P" }<br class="">}<br class=""><br class="">class A : P {<br class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>func foo() -> String { return "A" }<br class="">}<br class=""><br class="">class B : P {}<br class="">class C : B {<br class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>func foo() -> String { return "C" }<br class="">}<br class=""><br class="">A().foo() // A<br class="">(A() as P).foo() // A<br class="">B().foo() // P<br class="">(B() as P).foo() // P<br class="">C().foo() // C<br class="">(C() as P).foo() // P</font></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>