> Le 22 févr. 2017 à 17:53, BJ Homer <[email protected]> a écrit :
>
> My understanding is that “private” when written at file scope is exactly
> equivalent to “fileprivate”. That is, at the top level it’s tied to the file,
> not to the type’s scope. This means that the default access level within
> “private extension Foo {}” is actually *fileprivate*. This conflation of
> private and fileprivate is confusing.
>
> Example: This compiles:
>
> ---------------
>
> class Blah {
>
> func start() {
> self.test()
> }
> }
>
> private extension Blah {
> func test() {
>
> }
> }
>
> ---------------
>
> While this does not:
>
> ---------------
>
> class Blah {
>
> func start() {
> self.test()
> }
> }
>
> private extension Blah {
> private func test() { // Note the “private” here
>
> }
> }
Indeed, that appears to be confusing but, as you more than likely found out, if
you mark both the extension and its func as fileprivate, the problem goes away.
Nonetheless, with :
private extension Blah
{
func test()
{
}
}
… the test() method is not visible outside of the file because the extension is
private and, it would seem, that is enough to hide all of its code.
--
Joanna Carter
Carter Consulting
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution