[swift-evolution] [Pitch] Requiring proactive overrides for default protocol implementations.

Erica Sadun erica at ericasadun.com
Wed Apr 27 15:19:04 CDT 2016


On Apr 27, 2016, at 2:08 PM, Jérôme ALVES <j.alves at me.com> wrote:
> 
> What if... 
> 
> FooBar.framework defines :
> public protocol A {
>     func foo()
> }
> public type B: A {
>     public func foo () { 
>           … implementation … 
>     }
> }
> 
> Other module defines :
> import FooBar
> extension A {
>     func foo() { .. default implementation … }
> }
> 

Under these circumstances because of the mandatory import statement, there is no difference between the extension being defined in or outside the module, so long as the other module access is public. If it is not visible to the conforming protocol, there is no issue.

Conflicts of multiple protocol default implementations would need to be resolved exactly the same way as previously discussed, the only difference being namespacing:

required foo = OtherModule.A.foo

— E

> 
> Jérôme 
> 
> Le 27 avr. 2016 à 19:10, Erica Sadun via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> a écrit :
> 
>> protocol A {
>>     func foo()
>> }
>> 
>> extension A {
>>     func foo() { .. default implementation … }
>> }
>> 
>> type B: A {
>> 
>>     override required func foo () { … overrides implementation … }
>> }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160427/82b50b85/attachment.html>


More information about the swift-evolution mailing list