[swift-users] Protocol extension gotcha... or bug?

Wagner Truppel trupwl at gmail.com
Mon Jan 23 14:32:21 CST 2017


>> On 23 Jan 2017, at 19:56, Slava Pestov <spestov at apple.com> wrote:
>> 
>>> class B: A {
>>>  var item: String { // subclass specialises 'item' by "overriding" the protocol extension implementation
>> 
>> This is the problem. You’re not overriding the protocol extension version, you’re just shadowing it for the purposes of compile-time name lookup. Note that if you add the ‘override’ keyword here, the compiler complains because there’s nothing in the base class to override.

Yes, that's why I wrote overriding in quotes and also why I tried to use the word specialise in place of override. My beef is not really here; this really was just a preamble. My issue is with the fact that adding the declaration to the protocol doesn't solve the problem despite the fact that the property is then supposed to be dynamically dispatched but isn't.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20170123/0dde1e3b/attachment.html>


More information about the swift-users mailing list