<html><head><style>
body {
        font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
        padding:1em;
        margin:auto;
        background:#fefefe;
}

h1, h2, h3, h4, h5, h6 {
        font-weight: bold;
}

h1 {
        color: #000000;
        font-size: 28pt;
}

h2 {
        border-bottom: 1px solid #CCCCCC;
        color: #000000;
        font-size: 24px;
}

h3 {
        font-size: 18px;
}

h4 {
        font-size: 16px;
}

h5 {
        font-size: 14px;
}

h6 {
        color: #777777;
        background-color: inherit;
        font-size: 14px;
}

hr {
        height: 0.2em;
        border: 0;
        color: #CCCCCC;
        background-color: #CCCCCC;
    display: inherit;
}

p, blockquote, ul, ol, dl, li, table, pre {
        margin: 15px 0;
}

a, a:visited {
        color: #4183C4;
        background-color: inherit;
        text-decoration: none;
}

#message {
        border-radius: 6px;
        border: 1px solid #ccc;
        display:block;
        width:100%;
        height:60px;
        margin:6px 0px;
}

button, #ws {
        font-size: 12 pt;
        padding: 4px 6px;
        border-radius: 5px;
        border: 1px solid #bbb;
        background-color: #eee;
}

code, pre, #ws, #message {
        font-family: Monaco;
        font-size: 10pt;
        border-radius: 3px;
        background-color: #F8F8F8;
        color: inherit;
}

code {
        border: 1px solid #EAEAEA;
        margin: 0 2px;
        padding: 0 5px;
}

pre {
        border: 1px solid #CCCCCC;
        overflow: auto;
        padding: 4px 8px;
}

pre > code {
        border: 0;
        margin: 0;
        padding: 0;
}

#ws { background-color: #f8f8f8; }


.bloop_markdown table {
border-collapse: collapse;  
font-family: Helvetica, arial, freesans, clean, sans-serif;  
color: rgb(51, 51, 51);  
font-size: 15px; line-height: 25px;
padding: 0; }

.bloop_markdown table tr {
border-top: 1px solid #cccccc;
background-color: white;
margin: 0;
padding: 0; }
     
.bloop_markdown table tr:nth-child(2n) {
background-color: #f8f8f8; }

.bloop_markdown table tr th {
font-weight: bold;
border: 1px solid #cccccc;
margin: 0;
padding: 6px 13px; }

.bloop_markdown table tr td {
border: 1px solid #cccccc;
margin: 0;
padding: 6px 13px; }

.bloop_markdown table tr th :first-child, table tr td :first-child {
margin-top: 0; }

.bloop_markdown table tr th :last-child, table tr td :last-child {
margin-bottom: 0; }

.bloop_markdown blockquote{
  border-left: 4px solid #dddddd;
  padding: 0 15px;
  color: #777777; }
  blockquote > :first-child {
    margin-top: 0; }
  blockquote > :last-child {
    margin-bottom: 0; }

code, pre, #ws, #message {
    word-break: normal;
    word-wrap: normal;
}

hr {
    display: inherit;
}

.bloop_markdown :first-child {
    -webkit-margin-before: 0;
}

code, pre, #ws, #message {
    font-family: Menlo, Consolas, Liberation Mono, Courier, monospace;
}


.send { color:#77bb77; }
.server { color:#7799bb; }
.error { color:#AA0000; }</style></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class="bloop_markdown"><p>+1 :)</p>

<p>Let’s analyze this: public &gt; internal &gt; fileprivate &gt;= private</p>

<blockquote>
<p>An extension may optionally be marked with an explicit access modifier that specifies the default scope [see SE–0025]. However, such an explicit modifier <strong>must not match</strong> (or exceed) the original type’s access level.</p>
</blockquote>

<pre><code class="swift">public struct A {}

// I assume that we go with "must not match" here!

// can't be public anymore -&gt; no more  
// &lt;&lt;implicitly&gt;&gt; public extension members
// -&gt; breaking change -&gt; I can live with that
extension A {}

// no default access modifier -&gt; extension
// follows the access rule by the extended type A
// -&gt; here every extension member is internal by default
// -&gt; can be overridden to public member wise
extension A {}

// default access modifier acts as the upper bound
// inside an extended public type A
// -&gt; every extension member are fileprivate
// -&gt; extension member can be explicitly set to private
// -&gt; these will be only visible inside this extension scope
fileprivate extension A {}

// at file scope `private` acts like `fileprivate`  
// (if `private` is allowed at filescope) - haven't read the extended SE-0025 yet
// -&gt; I assume any member that are explicitly set to private
// will only be visible inside this extension scope
private extension A {}
</code></pre>

<p>Let’s check internal types:</p>

<pre><code class="swift">internal struct B {}

// "must not match" does not work here anymore
// do we use "must not exceed" here???

// I assume the second.

// doens't break anything
// works as before
// no default access modifier for internal types
// equals `internal extension A {}`
// members are default internal
// -&gt; can be overridden to `fileprivate` or scope level `private`
extension B {}

// same as for `public extension A`
fileprivate extension B {}

// same as for `public extension A`
private extension B {}

// that sounds fine right?

// let's check if we'd go with "must not match" instead:

// we cannot extend internal types with internal members
// anymore -&gt; ups, that would be really strange
extension B {}

// same as for `public extension A`
fileprivate extension B {}

// same as for `public extension A`
private extension B {}
</code></pre>

<p>Just for the record we also check <code>fileprivate</code> and <code>private</code>:</p>

<pre><code class="swift">fileprivate struct C {}

// "must not exceed" assumed

// no default access modifier means all  
// extension member will folow the upper bound by
// the extended type -&gt; fileprivate by default  
// -&gt; members can be set to be `private` and only
// visible inside this extension scope
// -&gt; equivalent to `fileprivate extension B {}`
// and `private extension C {}`
extension C {}

// "must not match" -&gt; would break like it breaks the  
// internal access model
</code></pre>

<p>``<code>swift
// at file scope acts like</code>fileprivate`
private struct D {}</p>

<p>// “must not exceed” assumed</p>

<p>// same as for <code>fileprivate</code>
extension D {}</p>

<p>// “must not match” -&gt; would break ```</p>

<p>Great compromise here!</p>

<blockquote>
<p>This rule would preserve the possibility of using extensions as grouping constructs. At the same time, it would (1) remove the possibility of writing public extension to default the access level of members to public; </p>
</blockquote>

<p>We still can group <code>internal</code> and <code>fileprivate</code> with this, but it’s okay I guess.</p>

<p>Let’s re-check default protocol implementation:</p>

<pre><code class="swift">public protocol G {
    func foo()
}

// currently we have 3 different ways to make them public
// #1
extension G {
    public func foo() { /* implement */ }
}

// #2
public extension G {
    func foo() { /* implement */ }
}

// #3
public extension G {
    public func foo() { /* implement */ }
}

// with "must not match" for `public` only #1 will work
// but everyone will need to repeat `public`  
// no laziness for `public` anymore - hurray
extension G {
    public func foo() { /* implement */ }
}

// "must not exceed" doesn't solve the problem of `public` at all
</code></pre>

<p>The last topic is conformance to protocols:</p>

<pre><code class="swift">public protocol P&nbsp;{}
internal protocol PI&nbsp;{}
fileprivate protocol PF&nbsp;{}
private protocol PP&nbsp;{}

public type Y {}

// "must not exceed" results in this, which is what it looks right now
extension Y : P {}

// just fine here
// we still can grant `PI` members visibility up to `public`
// the lower bound for these is `internal`
extension Y : PI {}

// same as `PI` but the lower bound is `fileprivate` now
extension Y : PF {}

// same as `PI` but the lower bound is `private` now
extension Y : PP {}

// this does not work atm.
// but should be allowed in general where we could grant visibility up to `internal`
internal extension Y : PI, PF, PP {}

fileprivate extension Y : PF, PP {}
</code></pre>

<p>There are a few more combinations I don’t want to type out here.</p>

<p>My conclusion it this:</p>

<ul>
<li><p>“must not match” does solve a few problems with <code>public</code> but only allows explicit <code>internal</code>, <code>fileprivate</code> and <code>private</code> usage, which is kinda odd. This is a new exceptional rule that must be documented.</p></li>
<li><p>“must not exceed” does not solve anything if it does not follow the typical public with default internal rule.</p>

<ol>
<li>With this exception it’s no more a default access modifier and totally useless on extensions, except if &gt;&gt;no access modifier&lt;&lt; would mean the upper bound is implicitly <code>internal</code> where you can’t grant visibility up to <code>public</code> and forced to use <code>public extension</code> if you wish to achieve this.</li>
<li>With the exception in (1) we would need to allow access modifier on extension with protocol conformance to achieve the same result everywhere.</li>
<li>With all that we’ll have to use #3 for default protocol implementations to make them public.</li>
</ol></li>
</ul>

<p>That said we’re end up with the same upper- lower bound access control model on extension I proposed, even if my proposal title and some of my writing there caused a lot of confusion.</p>

<p></p></div><div class="bloop_original_html"><style>body{font-family:Helvetica,Arial;font-size:13px}</style><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><br></div> <br> <div id="bloop_sign_1468834094443633920" class="bloop_sign"><div style="font-family:helvetica,arial;font-size:13px">--&nbsp;<br>Adrian Zubarev<br>Sent with Airmail</div></div> <br><p class="airmail_on">Am 18. Juli 2016 um 11:14:09, David Hart (<a href="mailto:david@hartbit.com">david@hartbit.com</a>) schrieb:</p> <blockquote type="cite" class="clean_bq"><span><div dir="auto"><div></div><div>



<title></title>


<div>This compromise solution looks very good to me. Thanks Xiaodi
for the effort put into working through our whining to come to the
best solution IMHO.</div>
<div><br>
On 18 Jul 2016, at 09:50, Xiaodi Wu via swift-evolution
&lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt;
wrote:<br>
<br></div>
<blockquote type="cite">
<div>
<div dir="ltr">All righty, thanks for all of your feedback. I've
worked on revising the proposal this evening, re-reading previous
documents and messages and re-analyzing what people meant. I think
Jose is absolutely right in the end, and the proposal has turned
out like he suggested. Here is the current draft below:
<div>
<div><br></div>
<div>
<h1 style="font-size:32px;margin-right:0px;margin-bottom:16px;margin-left:0px;line-height:1.5;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';margin-top:0px!important">
Harmonize access modifiers for extensions</h1>
<ul style="padding-left:2em;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px">
<li style="">Proposal:&nbsp;<a href="https://github.com/xwu/swift-evolution/blob/harmonize-access-modifiers/proposals/XXXX-harmonize-access-modifiers.md" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none">SE-XXXX</a></li>
<li style="margin-top:0.25em">Author:&nbsp;<a href="https://github.com/xwu" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none">Xiaodi
Wu</a></li>
<li style="margin-top:0.25em">Status:&nbsp;<span style="font-weight:600">Awaiting review</span></li>
<li style="margin-top:0.25em">Review manager: TBD</li>
</ul>
<h2 style="margin-top:1em;margin-bottom:16px;line-height:1.5;font-size:24px;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol'">
<a id="user-content-introduction" class="" href="https://github.com/xwu/swift-evolution/blob/harmonize-access-modifiers/proposals/XXXX-harmonize-access-modifiers.md#introduction" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none;display:inline-block;padding-right:2px;line-height:1">
</a>Introduction</h2>
<p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px">
During discussion of&nbsp;<a href="https://github.com/xwu/swift-evolution/blob/harmonize-access-modifiers/proposals/0119-extensions-access-modifiers.md" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none">SE-0119</a>,
some voiced concern that writing&nbsp;<code style="font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:14px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">public
extension</code>&nbsp;increases the default access level for
members declared within that extension, whereas
writing&nbsp;<code style="font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:14px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">public
class</code>&nbsp;or&nbsp;<code style="font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:14px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">public
struct</code>&nbsp;does not do the same.</p>
<p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px">
This behavior is explained as follows: since extensions have no
runtime representation and are not first-class entities, access
modifiers on extensions serve as a shorthand to set the default
access level for members. Certain members of the community have
indicated that such behavior makes extensions a natural grouping
construct.</p>
<p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px">
A general principle of Swift, recently strengthened by proposals
such as&nbsp;<a href="https://github.com/xwu/swift-evolution/blob/harmonize-access-modifiers/proposals/0117-non-public-subclassable-by-default.md" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none">SE-0117</a>,
has been that public API commitments should require explicit
opt-in. Given the different behavior of classes and structs, the
fact that extensions allow public methods to be declared without
spelling out&nbsp;<code style="font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:14px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">public</code>&nbsp;at
the declaration site has been called "confusing" or "odd."</p>
<p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px">
The aim of this proposal is to, in as conservative a manner as
possible, require explicit use of&nbsp;<code style="font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:14px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">public</code>&nbsp;for
public methods declared inside any extension.</p>
<p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px">
Swift-evolution threads:</p>
<ul style="padding-left:2em;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px">
<li style=""><a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160620/022144.html" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none">
[Proposal] Revising access modifiers on extensions</a></li>
<li style="margin-top:0.25em"><a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160711/024224.html" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none">
[Review] SE-0119: Remove access modifiers from extensions</a></li>
<li style="margin-top:0.25em"><a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160711/024522.html" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none">
[Draft] Harmonize access modifiers for extensions</a></li>
</ul>
<h2 style="margin-top:1em;margin-bottom:16px;line-height:1.5;font-size:24px;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol'">
<a id="user-content-motivation" class="" href="https://github.com/xwu/swift-evolution/blob/harmonize-access-modifiers/proposals/XXXX-harmonize-access-modifiers.md#motivation" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none;display:inline-block;padding-right:2px;line-height:1">
</a>Motivation</h2>
<p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px">
Consider the following:</p>
<pre style="font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:14px;margin-top:0px;margin-bottom:16px;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;color:rgb(51,51,51)"><code style="font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;padding:0px;margin:0px;background-color:transparent;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;border:0px;display:inline;overflow:visible;line-height:inherit;word-wrap:normal">public struct foo {
  func frobnicate() { } // internal
}
public extension foo { }

public struct bar { }
public extension bar {
  func frobnicate() { } // public
}
</code></pre>
<p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px">
This outcome is explained by rules regarding access modifiers
specifically on extensions&nbsp;<a href="https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/AccessControl.html" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none">Swift
2</a>, which is slated for preservation in Swift 3 as detailed
in&nbsp;<a href="https://github.com/xwu/swift-evolution/blob/harmonize-access-modifiers/proposals/0025-scoped-access-level.md" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none">SE-0025</a>.
However, it is arguably surprising that, of two declarations
spelled identically, one leads to a public API commitment while the
other does not.</p>
<h2 style="margin-top:1em;margin-bottom:16px;line-height:1.5;font-size:24px;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol'">
<a id="user-content-proposed-solution" class="" href="https://github.com/xwu/swift-evolution/blob/harmonize-access-modifiers/proposals/XXXX-harmonize-access-modifiers.md#proposed-solution" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none;display:inline-block;padding-right:2px;line-height:1">
</a>Proposed solution</h2>
<p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px">
The proposed solution is to amend access modifier rules to
eliminate the possibility of defaulting the access level of members
declared inside an extension to&nbsp;<code style="font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:14px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">public</code>.</p>
<h2 style="margin-top:1em;margin-bottom:16px;line-height:1.5;font-size:24px;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol'">
<a id="user-content-detailed-design" class="" href="https://github.com/xwu/swift-evolution/blob/harmonize-access-modifiers/proposals/XXXX-harmonize-access-modifiers.md#detailed-design" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none;display:inline-block;padding-right:2px;line-height:1">
</a>Detailed design</h2>
<p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px">
Amend access modifier rules as follows:</p>
<p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px">
An extension may optionally be marked with an explicit access
modifier that specifies the default scope [see SE-0025]. However,
such an explicit modifier&nbsp;<em style="">must not match (or
exceed) the original type's access level</em>.</p>
<p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px">
This rule would preserve the possibility of using extensions as
grouping constructs. At the same time, it would (1) remove the
possibility of writing&nbsp;<code style="font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:14px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">public
extension</code>&nbsp;to default the access level of members
to&nbsp;<code style="font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:14px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">public</code>;
and (2) clarify the notion that an access modifier on an extension
is a shorthand and not a way to create a first-class entity by
disallowing repeating of the original type's access level.</p>
<p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px">
<em style="">Explicit</em>&nbsp;access modifiers will continue to
set the maximum allowed access within an extension, as clarified in
SE-0025.</p>
<h2 style="margin-top:1em;margin-bottom:16px;line-height:1.5;font-size:24px;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol'">
<a id="user-content-alternatives-considered" class="" href="https://github.com/xwu/swift-evolution/blob/harmonize-access-modifiers/proposals/XXXX-harmonize-access-modifiers.md#alternatives-considered" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none;display:inline-block;padding-right:2px;line-height:1">
</a>Alternatives considered</h2>
<p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px">
One alternative is to eliminate explicit access modifiers on
extensions altogether. As an advantage, this would further clarify
the mental model that extensions are not their own first-class
entities. As a disadvantage, extensions cease to be an access
modifier grouping construct, which some users really like.</p>
<h2 style="margin-top:1em;margin-bottom:16px;line-height:1.5;font-size:24px;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol'">
<a id="user-content-acknowledgments" class="" href="https://github.com/xwu/swift-evolution/blob/harmonize-access-modifiers/proposals/XXXX-harmonize-access-modifiers.md#acknowledgments" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none;display:inline-block;padding-right:2px;line-height:1">
</a>Acknowledgments</h2>
<p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px">
Thanks to all discussants on the list, especially Adrian Zubarev,
Jose Cheyo Jimenez, and Paul Cantrell.</p>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote"><br></div>
<div class="gmail_quote">On Sun, Jul 17, 2016 at 11:08 AM, Xiaodi
Wu <span dir="ltr">&lt;<a href="mailto:xiaodi.wu@gmail.com" target="_blank">xiaodi.wu@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I
understand how it works.<br>
<br>
By aligning access modifier rules inside extensions with those
inside types, all other modifiers would continue to work as it does
now (implicitly internal members would be limited by the upper
bound). The only change in this respect is removing the ability to
have public API without writing `public func`.
<div class="HOEnZb">
<div class="h5"><br>
<div class="gmail_quote">
<div dir="ltr">On Sun, Jul 17, 2016 at 11:01 Adrian Zubarev via
swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;
wrote:<br></div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word">
<div>
<p>I tackled it as an upper bound but highly rejected by the
community. That’s exactly what my proposal was all about. An upper
boundary would be more elegant, but I still see arguments ‘because
it’s not a type’.</p>
<p>I could live without access modifiers on extensions in
general.</p>
</div>
</div>
<div style="word-wrap:break-word">
<div>
<blockquote>
<p>The default access modifier rule permits public methods to be
written without <code>public func</code></p>
</blockquote>
</div>
</div>
<div style="word-wrap:break-word">
<div>
<p>You meant this?</p>
<pre><code>public extension SomeType {
    // I don't need to write public
    func foo() {}
    var computed: Type {}
}
</code></pre>
<p>This applies to all access modifiers which are not optional
(like internal):</p>
<pre><code>public SomeType
fileprivate extension SomeType {
    // I don't need to repeat fileprivate
    func foo() {}
    var computed: Type {}
}

// which is more likely `fileprivate` because it's on file scope
private extension SomeType {
    // even if the inner access modifier would pretend to be private
    // since the extension is on filescope, everything will be `fileprivate`
    func foo() {}
    var computed: Type {}
}
</code></pre></div>
</div>
<div style="word-wrap:break-word">
<div>
<div style="font-family:Helvetica,Arial;font-size:13px;color:rgba(0,0,0,1.0);margin:0px;line-height:auto">
<br></div>
<br>
<div>
<div style="font-family:helvetica,arial;font-size:13px">
--&nbsp;<br>
Adrian Zubarev<br>
Sent with Airmail</div>
</div>
<br></div>
</div>
<div style="word-wrap:break-word">
<div>
<p>Am 17. Juli 2016 um 17:50:31, Xiaodi Wu (<a href="mailto:xiaodi.wu@gmail.com" target="_blank">xiaodi.wu@gmail.com</a>) schrieb:</p>
<blockquote type="cite">
<div>
<div><span>The proposal is that the access modifier for an
extension will either be removed entirely or remain as an upper
bound, losing its function as a default access modifier. The
default access modifier rule permits public methods to be written
without `public func`; this is a proposal to remove that feature
because it is a source of confusion.<br></span>
<div class="gmail_quote">
<div dir="ltr"><span>On Sun, Jul 17, 2016 at 10:43 Adrian Zubarev
via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;
wrote:<br></span></div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word">
<div>
<p><span>I still don’t catch to point here. There is no
<code>implicit public</code> there. It’s explicit set by the
default access modifier of extensions. It’s how they work and how
they should remain (at least as long the community want
<code>default access modifier</code> to exist on extensions).
Disallowing setting <code>public</code> on extensions when you
extend a public type makes no sense. If you want your member to be
<code>internal</code> like it’s in types, then remove the access
modifier from extension and all member will follow the type access
modifier.</span></p>
</div>
</div>
<div style="word-wrap:break-word">
<div>
<div style="font-family:Helvetica,Arial;font-size:13px;color:rgba(0,0,0,1.0);margin:0px;line-height:auto">
<span><br></span></div>
<span><br></span>
<div>
<div style="font-family:helvetica,arial;font-size:13px">
<span>--&nbsp;<br>
Adrian Zubarev<br>
Sent with Airmail</span></div>
</div>
<span><br></span></div>
</div>
<div style="word-wrap:break-word">
<div>
<p><span>Am 17. Juli 2016 um 17:37:02, Xiaodi Wu (<a href="mailto:xiaodi.wu@gmail.com" target="_blank">xiaodi.wu@gmail.com</a>) schrieb:</span></p>
<blockquote type="cite">
<div>
<div>
<div dir="ltr"><span><span>That's a good point. I will incorporate
these into a revised draft. Only two things will
change:</span></span>
<div><span><br></span></div>
<div><span>```</span></div>
<div><span>public struct Foo {</span></div>
<div><span>&nbsp; // implicitly internal</span></div>
<div><span>&nbsp; func frobnicate1() { }</span></div>
<div><span>}<br></span></div>
<div><span>public extension Foo {</span></div>
<div><span>&nbsp; // currently implicitly public</span></div>
<div><span>&nbsp; //</span></div>
<div><span>&nbsp; // depending on which alternative is
adopted,</span></div>
<div><span>&nbsp; // the proposal will either prohibit `public
extension`</span></div>
<div><span>&nbsp; // or this method will be implicitly
internal</span></div>
<div><span>&nbsp; func frobnicate2() { }</span></div>
<div><span>}<br></span></div>
<div><span>```</span></div>
<div><span><br></span></div>
<div><span>```</span></div>
<div><span>internal struct Bar {</span></div>
<div><span>&nbsp; // permitted by SE-0025 without a
warning</span></div>
<div><span>&nbsp; // this method can only be accessed within module
anyway</span></div>
<div><span>&nbsp; // because `internal struct` bounds access of its
members</span></div>
<div><span>&nbsp; public func frobnicate1() { }</span></div>
<div><span>}<br></span></div>
<div><span>extension Bar {</span></div>
<div><span>&nbsp; // not permitted by SE-0025</span></div>
<div><span>&nbsp; //</span></div>
<div><span>&nbsp; // after proposal, this will also be permitted
without a warning</span></div>
<div><span>&nbsp; // and this method will also be accessible only
within module</span></div>
<div><span>&nbsp; public func frobnicate2() { }</span></div>
<div><span>}</span></div>
<div><span>```</span></div>
<div class="gmail_extra"><span><br></span>
<div class="gmail_quote"><span>On Sun, Jul 17, 2016 at 1:50 AM,
Adrian Zubarev via swift-evolution <span dir="ltr">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;</span>
wrote:<br></span>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div style="word-wrap:break-word">
<div>
<p>I’m struggling to understand your proposal, can you provide some
specific code samples how it works now and what will change. The
example from the draft doesn’t help my understanding. :/</p>
</div>
<div>
<div style="font-family:Helvetica,Arial;font-size:13px;color:rgb(0,0,0);margin:0px">
<span><br></span></div>
<span><br></span>
<div>
<div style="font-family:helvetica,arial;font-size:13px">
<span>--&nbsp;<br>
Adrian Zubarev<br>
Sent with Airmail</span></div>
</div>
<span><br></span>
<div>
<div>
<p>Am 17. Juli 2016 um 04:40:45, Xiaodi Wu via swift-evolution
(<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>) schrieb:</p>
<blockquote type="cite">
<div>
<div>
<div dir="ltr">
<div class="gmail_extra">
<div class="gmail_quote"><span>On Sat, Jul 16, 2016 at 7:56 PM,
Jose Cheyo Jimenez <span dir="ltr">&lt;<a href="mailto:cheyo@masters3d.com" target="_blank">cheyo@masters3d.com</a>&gt;</span> wrote:<br></span>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div dir="auto">
<div>I think you can simplify this proposal by just saying
something like this and give a couple of examples that are easy to
follow:</div>
<div><br></div>
<div>Disallow explicit public access modifier on
non-protocol-conforming type extensions.</div>
</div>
</blockquote>
<div><br></div>
<div>It took me a while to process what you're trying to say here,
but this is a good idea and would go along well with the first
draft's proposed solution. I will spell it out. (If we say that you
can use an explicit modifier only to lower the access level of
members, then `public` as an explicit modifier could be entirely
disallowed.)</div>
<div>&nbsp;</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div dir="auto">
<div><br></div>
<div>I think if you only focus on that breaking change then the
proposal will have a good chance of getting accepted and fixing the
immediate issue of public. There is a reason why protocol
conforming extensions do not allow explicitly saying
public&nbsp;</div>
<div>`public extension Type: Protocol {}` // public not
allowed&nbsp;</div>
</div>
</blockquote>
<div><br></div>
<div>Actually, no modifiers are allowed in that scenario,
IIUC.</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div dir="auto">
<div><br></div>
<div>In essence we will be asking for the same behavior for
types.&nbsp;</div>
<div><br></div>
<div>Allowing methods declared inside extensions to have a higher
declared visibility is not a breaking change and can be introduced
later.&nbsp;</div>
</div>
</blockquote>
<div><br></div>
<div>It is a breaking change in that I am proposing that the rules
be harmonized so that the implicit default access level will be
notionally `internal` (there are follow-on benefits to this
change). That cannot be changed later.</div>
<div>&nbsp;</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div dir="auto">
<div>Nobody wants private extensions or implicit internal
extensions to go away. :)</div>
</div>
</blockquote>
<div><br></div>
<div>I know that there are people who don't want it to go away.
That was why the first draft proposed keeping them, but it sounds
like it would make for an illogical system. I know that Jordan and
John have both indicated that they don't think it's worth keeping
around but don't seem to feel too strongly about it, and I think I
feel the same way (leaning towards not keeping them, but don't feel
very strongly). I will definitely feature this concern (using
extensions as access modifier groups) prominently in the proposal
and hope for a robust discussion to see how it plays out with the
community and core team.</div>
<div><br></div>
<div><br></div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div dir="auto">
<div>
<div>
<div><br>
On Jul 16, 2016, at 4:22 PM, Xiaodi Wu via swift-evolution
&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br>
<br></div>
<blockquote type="cite">
<div>
<div dir="ltr">
<div class="gmail_extra">
<div class="gmail_quote">On Sat, Jul 16, 2016 at 6:10 PM, David
Hart <span dir="ltr">&lt;<a href="mailto:david@hartbit.com" target="_blank">david@hartbit.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div dir="auto">
<div>This proposal really confuses me. Two comments:</div>
<div><br></div>
<div>1) With the proposal, we loose the ability to use access
modifiers on extensions as a way of grouping members by access.
That's a huge loss for me.</div>
</div>
</blockquote>
<div><br></div>
<div>You lose the ability to group public members only. That part
is intentional, so that only methods declared with `public func`
are public.</div>
<div>&nbsp;</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div dir="auto">
<div>2) If we adopt the proposal, I now have no idea what explicit
access modifiers on extensions do.</div>
</div>
</blockquote>
<div><br></div>
<div>I propose keeping explicit access modifiers because previous
comments on this list have said that it's useful for grouping
members by access. You can continue to use extensions to group
fileprivate members of an internal type, or internal members of a
public type.</div>
<div><br></div>
<div>&nbsp;</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div dir="auto">
<div>More generally, I don't understand this proposal as it's
trying to apply the same access modifier rules on extensions as for
types but extensions are not types. They are just a declaration for
extending types which already have an access level.</div>
<div>
<div>
<div><br>
On 16 Jul 2016, at 20:04, Xiaodi Wu via swift-evolution
&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br>
<br></div>
<blockquote type="cite">
<div>
<div dir="ltr">With the impending withdrawal of SE-0119 and the
closing window for (most) source-breaking changes, I thought I'd
draft up a proposal to address some of the key points raised in
that discussion.
<div><br></div>
<div>The proposed changes are deliberately limited in scope to
rationalizing access modifier rules without adding any new
facilities (such as conformances of lower visibility than the
type), which might be more appropriate for the Swift 4
timeline.</div>
<div><br></div>
<div>I hope this will prove satisfactory to the community :)</div>
<div><br></div>
<div><br></div>
<div>
<h1 style="font-size:32px;margin-right:0px;margin-bottom:16px;margin-left:0px;line-height:1.5;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';margin-top:0px!important">
Harmonize access modifiers for extensions</h1>
<ul style="padding-left:2em;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px">
<li>Proposal:&nbsp;<a href="https://github.com/xwu/swift-evolution/blob/harmonize-access-modifiers/proposals/XXXX-harmonize-access-modifiers.md" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none" target="_blank">SE-XXXX</a></li>
<li style="margin-top:0.25em">Author:&nbsp;<a href="https://github.com/xwu" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none" target="_blank">Xiaodi Wu</a></li>
<li style="margin-top:0.25em">Status:&nbsp;<span style="font-weight:600">Awaiting review</span></li>
<li style="margin-top:0.25em">Review manager: TBD</li>
</ul>
<h2 style="margin-top:1em;margin-bottom:16px;line-height:1.5;font-size:24px;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol'">
<a href="https://github.com/xwu/swift-evolution/tree/harmonize-access-modifiers#introduction" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none;display:inline-block;padding-right:2px;line-height:1" target="_blank"></a>Introduction</h2>
<p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px">
During discussion of&nbsp;<a href="https://github.com/xwu/swift-evolution/blob/harmonize-access-modifiers/proposals/0119-extensions-access-modifiers" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none" target="_blank">SE-0119</a>, the community articulated the view
that access modifiers for extensions were and should continue to be
subject to the same rules as access modifiers for types.
Unfortunately, it is not factually true today; this proposal aims
to make it so.</p>
<p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px">
Swift-evolution threads:</p>
<ul style="padding-left:2em;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px">
<li><a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160620/022144.html" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none" target="_blank">[Proposal] Revising access modifiers on
extensions</a></li>
<li style="margin-top:0.25em">[More to be added here]</li>
</ul>
<h2 style="margin-top:1em;margin-bottom:16px;line-height:1.5;font-size:24px;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol'">
<a href="https://github.com/xwu/swift-evolution/tree/harmonize-access-modifiers#motivation" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none;display:inline-block;padding-right:2px;line-height:1" target="_blank"></a>Motivation</h2>
<p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px">
Consider the following:</p>
<pre style="font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:14px;margin-top:0px;margin-bottom:16px;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;color:rgb(51,51,51)"><code style="font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;padding:0px;margin:0px;background-color:transparent;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;border:0px;display:inline;overflow:visible;line-height:inherit;word-wrap:normal">public struct foo {
  func frobnicate() { } // implicitly internal
}
public extension foo { }

public struct bar { }
public extension bar {
  func frobnicate() { } // implicitly public, according to SE-0025
}
</code></pre>
<p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px">
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.</p>
<p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px">
Furthermore, SE-0025 now permits the owner of a type to design
access for members as though the type will have a higher access
level than it currently does. For example, users will be able to
design&nbsp;<code style="font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:14px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">public</code>&nbsp;methods
inside an&nbsp;<code style="font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:14px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">internal</code>type
before "flipping the switch" and making that type&nbsp;<code style="font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:14px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">public</code>.
The same approach is prohibited by SE-0025 for extensions, although
conceptually it need not be.</p>
<h2 style="margin-top:1em;margin-bottom:16px;line-height:1.5;font-size:24px;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol'">
<a href="https://github.com/xwu/swift-evolution/tree/harmonize-access-modifiers#proposed-solution" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none;display:inline-block;padding-right:2px;line-height:1" target="_blank"></a>Proposed solution</h2>
<p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px">
The proposed solution is to change access modifier rules for
extensions with the following effect: if any method (or computed
property) declared within the body of a type at file scope is moved
without modification into the body of an extension in the same
file, the move will not change its accessibility.</p>
<p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px">
In code:</p>
<pre style="font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:14px;margin-top:0px;margin-bottom:16px;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;color:rgb(51,51,51)"><code style="font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;padding:0px;margin:0px;background-color:transparent;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;border:0px;display:inline;overflow:visible;line-height:inherit;word-wrap:normal">struct foo {
  // Any method declared here...
}
extension foo {
  // ...should have the same visibility when moved here.
}
</code></pre>
<p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px">
This implies that public API commitments will need to be annotated
as&nbsp;<code style="font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:14px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">public</code>&nbsp;at
declaration sites inside an extension just as it must be at
declaration sites inside types.</p>
<h2 style="margin-top:1em;margin-bottom:16px;line-height:1.5;font-size:24px;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol'">
<a href="https://github.com/xwu/swift-evolution/tree/harmonize-access-modifiers#detailed-design" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none;display:inline-block;padding-right:2px;line-height:1" target="_blank"></a>Detailed design</h2>
<ol style="padding-left:2em;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px">
<li>Declarations inside the extension will, like declarations
inside types, have a default access level of&nbsp;<code style="font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:14px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">internal</code>.</li>
<li style="margin-top:0.25em">The compiler should not warn when a
broader level of access control is used for a method (or computed
property, etc.) declared within an extension with more restrictive
access. This allows the owner of the extension to design the access
level they would use for a method if the type or extension were to
be made more widely accessible.</li>
<li style="margin-top:0.25em">An extension declared without an
explicit access modifier will have the same access level as the
type being extended.</li>
<li style="margin-top:0.25em">An extension declared without
protocol conformance may optionally use an explicit access modifier
to provide an upper bound for the visibility of its members.</li>
</ol>
<h2 style="margin-top:1em;margin-bottom:16px;line-height:1.5;font-size:24px;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol'">
<a href="https://github.com/xwu/swift-evolution/tree/harmonize-access-modifiers#alternatives-considered" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none;display:inline-block;padding-right:2px;line-height:1" target="_blank"></a>Alternatives considered</h2>
<ul style="padding-left:2em;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px">
<li>One alternative, still open for consideration, is to eliminate
#4 and disallow explicit access modifiers on extensions. As an
advantage, this would clarify the mental model that extensions are
not their own entities, as they cannot be referred to by name and
have no runtime representation. As a disadvantage, extensions cease
to be an access modifier grouping construct, which some users
really like.</li>
</ul>
<h2 style="margin-top:1em;margin-bottom:16px;line-height:1.5;font-size:24px;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol'">
<a href="https://github.com/xwu/swift-evolution/tree/harmonize-access-modifiers#acknowledgments" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none;display:inline-block;padding-right:2px;line-height:1" target="_blank"></a>Acknowledgments</h2>
<p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px">
Thanks to all discussants on the list, especially Adrian Zubarev
and Jose Cheyo Jimenez.</p>
</div>
</div>
</div>
</blockquote>
</div>
</div>
<blockquote type="cite">
<div>
<span>_______________________________________________</span><span><br>

<span>swift-evolution mailing list</span><br>
<span><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a></span><br>
<span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br>
</span></div>
</blockquote>
</div>
</blockquote>
</div>
<br></div>
</div>
</div>
</blockquote>
<blockquote type="cite">
<div>
<span>_______________________________________________</span><br>
<span>swift-evolution mailing list</span><br>
<span><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a></span><br>
<span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br>
</div>
</blockquote>
</div>
</div>
</div>
</blockquote>
</div>
<br></div>
</div>
_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</div>
</div>
</blockquote>
</div>
</div>
</div>
</div>
<br>
_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>

<br></blockquote>
</div>
<br></div>
</div>
</div>
</div>
</blockquote>
</div>
</div>
_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</blockquote>
</div>
</div>
</div>
</blockquote>
</div>
</div>
_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</blockquote>
</div>
</div>
</div>
</blockquote>
</div>
<br></div>
</div>
</div>
</div>
</blockquote>
<blockquote type="cite">
<div>
<span>_______________________________________________</span><br>
<span>swift-evolution mailing list</span><br>
<span><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a></span><br>

<span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br>
</div>
</blockquote>


</div></div></span></blockquote></div><div class="bloop_markdown"><p></p></div></body></html>