[swift-evolution] classprivate protection level?

Mike Kluev mike.kluev at gmail.com
Mon Oct 30 13:19:34 CDT 2017

On 30 October 2017 at 18:07, Adam Kemp <adam_kemp at apple.com> wrote:

> On Oct 30, 2017, at 10:57 AM, Mike Kluev <mike.kluev at gmail.com> wrote:
> the new bucket would be "class and all of its extensions be them in the
> same file or in different files”.
> That’s not a new bucket. It is equivalent to either internal or public,
> depending on whether you want to extend this beyond the module boundary.
> The set of code you would have to audit is the same.

it is different, see below:

=== file: Some.swift

class Some {
   internal func foo() {
   classprivate func better() {

=== file: Some+Bar.swift

extension Some {
  internal func bar() {
  classprivate func good() {

=== any other file (same module)

class Other {
    func x() {
        let some = Some()

        some.foo() // ************** UNWANTED!!!!!!

        some.better() // error.  ****** WANTED!

I do not want to audit the class Other when I make a change to "foo" or
"bar", which are essentially "private" and only made "internal" because of
the language limitation in regards to "private" vs "multi-file class" issue.

> What does marking a method as “specialprivate” (my made up name for this
> new access level) tell clients about who can use it or how it can be used?

it tells them: "you can't use this, unless you are writing an extension to
this class or making changes to this class itself"

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20171030/10827c39/attachment.html>

More information about the swift-evolution mailing list