[swift-evolution] Small Enhancement Request for Swift Protocol

Andrew Trick atrick at apple.com
Tue May 17 13:10:50 CDT 2016


> On May 14, 2016, at 7:49 AM, Sreejith K R via swift-evolution <swift-evolution at swift.org> wrote:
> 
> Hello All,
> 
> 
> I would like to suggest an enhancement for the swift protocol would really like this feature to be reviewed.
> 
> Enhancement Description : 
> 
> Currently it is not possible to invoke  the default implementation of a particular protocol (EG: SampleProtocolParent achieved using protocol extension)  inside   another protocol extention(Eg: SampleProtocolSub) that inherits from the former protocol. Please look  into the SampleProtocolSub extension as shown below. Also the same behavior is observed  while a class implements the protocol(Please look  into the Test class that implements SampleProtocolSub as shown below ). 
> 
>  This behavior is something similar to the usage of super keyword while overriding a method. 
> 
> protocol SampleProtocolParent{
>     func testFunction();
>     
> }
> extension SampleProtocolParent{
>     func testFunction(){
>             print("hello my super implementation")
>     }
> 
> }
> protocol SampleProtocolSub:SampleProtocolParent{
>     
>     
> }
> 
> extension SampleProtocolSub{
>     func testFunction(){
>        /* need to call testFunction implementation of the parent SampleProtocolParent as well here. Is this a possible feature  ?*/
>         print("hello my current and new implementation")
>     }
>     
> }
> 
> class Test:SampleProtocolSub{
>     func testFunction(){
>         
>         /* need to call testFunction implmentaion of the parent SampleProtocolParent as well here. Is this a possible feature  ?*/
>         print("hello my current and new new new implementaion")
>     }
> }

I also want this feature, but haven’t seen any proposed syntax.
-Andy



More information about the swift-evolution mailing list