[swift-evolution] [PROPOSAL]Return subclass type to a protocol where a superclass is defined without the need for associatedtype
Yogev Sitton
yogev.sitton at gmail.com
Mon Apr 18 05:01:45 CDT 2016
I’m referring you to Ross O’Brien’s post:
As of Swift 2.2, if a variable has a closure type of e.g. () -> Shape, a closure of type () -> Circle would be considered a match. If a class implements 'func make() -> Shape', a subclass implementing 'func make() -> Circle' has to override. However, if a protocol requires a 'func make() -> Shape', a type implementing 'func make() -> Circle' isn't considered to be conforming. That does seem strange.
Protocols behaves differently than closures and classes and I think they should behave the same.
> On Apr 18, 2016, at 1:00 PM, Gwendal Roué <gwendal.roue at gmail.com> wrote:
>
>
>> Le 18 avr. 2016 à 11:53, Yogev Sitton <yogev.sitton at gmail.com> a écrit :
>>
>> Hi Gwendal,
>>
>> I’m actually trying to start a discussion that will change the current behavior of the language.
>> That’s why I posted this on the swift-evolution mailing list and not swift-users.
>
> OK Yogev. But what is the problem actually? If some of your code does not do what you want, is it because of the language, or is it because you still have to learn something about the language?
>
> Associated types are not a "hack", they are a feature. Maybe you are not using it properly, you see?
>
> If you would tell how those MyShapeProtocol objects are used, it may get clearer.
>
> Gwendal
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160418/ca444bf0/attachment.html>
More information about the swift-evolution
mailing list