<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=""><br class=""><div><blockquote type="cite" class=""><div class="">On Feb 22, 2017, at 1:01 PM, David Hart <<a href="mailto:david.w.hart@me.com" class="">david.w.hart@me.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On 22 Feb 2017, at 21:59, Slava Pestov 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=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div 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></div></blockquote><div class=""><br class=""></div><div class="">What do you mean by “address” this? Force the vtable entry?</div></div></div></div></blockquote><div><br class=""></div>Yeah. Instead of having the witness table for the conformance point directly to the extension method, if the conforming type is a class, we will generate a small thunk that calls a vtable entry, and store the extension method in that vtable entry.</div><div><br class=""></div><div>Of course this will only work if the conformance is defined in the same translation unit as the class; if you define the extension in a different module, you’ll get the same behavior you observe below.</div><div><br class=""></div><div>Slava</div><div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Slava</div><div class=""><br class=""></div><br class=""><div class=""><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=""><a href="https://lists.swift.org/mailman/listinfo/swift-users" class="">https://lists.swift.org/mailman/listinfo/swift-users</a><br class=""></div></blockquote></div><br class=""></div>_______________________________________________<br class="">swift-users mailing list<br class=""><a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-users" class="">https://lists.swift.org/mailman/listinfo/swift-users</a><br class=""></div></blockquote></div><br class=""></div></div></blockquote></div><br class=""></body></html>