[swift-evolution] [Proposal] Nested extensions
Xiaodi Wu
xiaodi.wu at gmail.com
Sat Apr 15 11:26:21 CDT 2017
The rules are laid out in SE-0025. What you are finding is that SE-0025 is
not yet fully implemented.
On Sat, Apr 15, 2017 at 11:04 Tino Heth <2th at gmx.de> wrote:
> Am 15.04.2017 um 17:33 schrieb Xiaodi Wu <xiaodi.wu at gmail.com>:
>
> I think you misunderstand how access modifiers currently work with
> extensions. It is not permitted to use an access modifier inside an
> extension that is higher than that of the extension itself.
>
>
> class Check {}
>
> fileprivate extension Check {
> public func px() {
> print("It compiles!")
> }
> }
>
> Check().px()
>
> This code executes without complains — but your example is right, it fails
> if the extension is marked private… wtf? Access modifiers aren't even
> mentioned in
> https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/Extensions.html#//apple_ref/doc/uid/TP40014097-CH24-ID151
>
> It really seems to me that the current extension-model is somewhat broken;
> do you have a link to documentation of access levels for extensions?
>
> ```
> private struct S {
> private extension {
> func f() { } // what is the access level of `f`?
> }
> }
> ```
>
> If `f` is private, then it is invisible outside the extension. But `f`
> cannot be `fileprivate`, because `fileprivate` is more visible than the
> private extension and is therefore not allowed.
>
> I'd simply say f is private and only visible inside the extension…
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170415/c551e336/attachment.html>
More information about the swift-evolution
mailing list