[swift-evolution] [Draft] Harmonize access modifiers for extensions

Adrian Zubarev adrian.zubarev at devandartist.com
Sat Jul 16 13:13:22 CDT 2016


Have you by any chance meant this?

You can extend a class, structure, or enumeration in any access context in which the class, structure, or enumeration is available. Any type members added in an extension have the same default access level as type members declared in the original type being extended. If you extend a public or internal type, any new type members you add will have a default access level of internal. If you extend a private type, any new type members you add will have a default access level of private.

[HERE]: Alternatively, you can mark an extension with an explicit access level modifier (for example, private extension) to set a new default access level for all members defined within the extension.

This new default can still be overridden within the extension for individual type members.

Source
This is not according SE–0025 to me. It’s how access control on extensions worked all the time (which I misunderstood when posting my first draft).



-- 
Adrian Zubarev
Sent with Airmail

Am 16. Juli 2016 um 20:04:38, Xiaodi Wu via swift-evolution (swift-evolution at swift.org) schrieb:

According to SE-0025, a method moved from the body of a public struct into a public extension becomes public without modification. This is surprising behavior contrary to Swift's general rule of not exposing public API by default.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160716/38aa7491/attachment.html>


More information about the swift-evolution mailing list