[swift-evolution] [Proposal] Revising access modifiers on extensions

Adrian Zubarev adrian.zubarev at devandartist.com
Mon Jun 27 17:17:29 CDT 2016


If you want consistent behavior, the proposal should just be “remove access modifiers from extensions”. That way, access for members follows the same defaults as in the original type. The only purpose for access modifiers on extensions is to change the default, so if you don’t like the behavior of changing the default, then the feature should be removed.
I’m a little confused right now, because to me “remove access modifiers from extensions” sounds like there will be no access modifier at all.

And yes I indeed don’t like that behavior, because it has a lot potential of confusion. Don’t get me wrong, now I do understand how it works, but the way it behaves is strange.

If we’d remove this feature, would extensions automatically work like I described in the proposal?

internal protocol A {
    func foo()
}

public struct B {}

// A is hidden
public extension B : A {
     
    // `foo` can be made visible
    public func foo() {}
}

// extension will be imported as

public extension B {
    public func foo()
}
Anything else I made need to change to drive my proposal into that direction?

I really appreciate your feedback. :)



-- 
Adrian Zubarev
Sent with Airmail

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160628/5321d2d7/attachment.html>


More information about the swift-evolution mailing list