[swift-evolution] [Draft] Remove support for final in protocol extensions

Brian King brianaking at gmail.com
Tue Mar 7 21:23:22 CST 2017


Hey Folks, This draft proposal addresses starter bug SR-1762. I believe
this is in scope for Swift 4 since it impacts source compatibility. It's
not a very exciting proposal, but I think it will help make Swift a little
more consistent.

https://gist.github.com/KingOfBrian/6f20c566114ac0ef54c8092d80e54ee7
https://bugs.swift.org/browse/SR-1762

Thanks

Brian
Introduction

This proposal suggests removing support for the final keyword when
declaring a function in a protocol extension. The presence of the final keyword
does not currently generate an error message, and it does not actually
modify the dispatch behavior in any way.
<https://gist.github.com/KingOfBrian/6f20c566114ac0ef54c8092d80e54ee7#motivation>
Motivation

In the original protocol model of Swift, a developer could use the
final keyword
when declaring a function in a protocol extension to ensure the function
could not be overridden. This keyword has no use in Swift's current
protocol model, since functions in protocol extensions can not be
overridden and will always use direct dispatch.
<https://gist.github.com/KingOfBrian/6f20c566114ac0ef54c8092d80e54ee7#detailed-design>Detailed
design

The compiler should generate an error or warning when the final keyword is
used on a function declaration inside of a protocol extension. This is
consistent with the use of final in structs and enumerations.
<https://gist.github.com/KingOfBrian/6f20c566114ac0ef54c8092d80e54ee7#source-compatibility>Source
compatibility

This change will impact source compatibility. To maintain compatibility
with Swift 3, a warning will be generated in Swift 3 mode instead of an
error message.
<https://gist.github.com/KingOfBrian/6f20c566114ac0ef54c8092d80e54ee7#effect-on-abi-stability>Effect
on ABI stability

This has no effect on ABI stability
<https://gist.github.com/KingOfBrian/6f20c566114ac0ef54c8092d80e54ee7#effect-on-api-resilience>Effect
on API resilience

This has no effect on API resilience
<https://gist.github.com/KingOfBrian/6f20c566114ac0ef54c8092d80e54ee7#alternatives-considered>Alternatives
considered

The only alternative would be to not fix this bug
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170307/de8466e3/attachment.html>


More information about the swift-evolution mailing list