That is a different discussion entirely.  Once you fall below internal then we 
do not default to internal, we default to the maximum access level of the outer 
decl.  Read that linked part of the type checker if you don't believe me.  I 
also had to fix several hundred lines of SwiftPM and corelibs code that was 
failing to build because of this exact access control schema in 
apple/swift#3000.  You'll notice I effectively changed two lines in Sema and 
this was the fallout.  I did nothing special to change our existing access 
control mechanism, it's just how it has always worked.  Try declaring this 
explicitly and see the diagnostic we emit, then it'll be easier to see why this 
is a problem:

private struct X {
   internal var x : String = "" // expected-warning
}

~Robert Widmann

2016/06/15 18:47、Charles Srstka <cocoa...@charlessoft.com> のメッセージ:

>> On Jun 15, 2016, at 8:36 PM, Robert Widmann <devteam.cod...@gmail.com> wrote:
>> 
>> Point 3 is *not* how member lookup applies access control levels to 
>> unannotated properties of outer structures (see 
>> https://github.com/CodaFi/swift/blob/fb9f9536a5760369457d0f9c49599415cbc36e07/lib/Sema/TypeCheckDecl.cpp#L1470)
>>  and makes no sense.  They do not default to "internal" when unannotated, 
>> they default to the highest possible access level they can get given the 
>> decl they're in.  A private structure will necessarily have private members. 
>>  This is the whole point of me raising this issue.  If we were to break 
>> containment we would break the very motivation for this proposal.  And if we 
>> wish to do this to get this feature right, then the proposal needs to be 
>> amended to include that kind of caveat.
> 
> This isn’t correct. If the outer type is marked “public”, and its properties 
> are not annotated, those properties will be internal, *not* public, and you 
> will not be able to see them outside of the module.
> 
> The rule can basically be summed up as “internal by default, unless we can’t 
> because our enclosing type is more restrictive than internal. Then, be as 
> visible as the enclosing type is."
> 
> Charles
> 
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to