[swift-evolution] [swift-evolution-announce] [Review] SE-0159: Fix Private Access Levels

Shawn Erickson shawnce at gmail.com
Tue Mar 21 11:59:30 CDT 2017


I have a few cases like that in production code with an unthread safe
private function shadows a more public function that applies thread safety
for external callers, etc.

-Shawn

On Tue, Mar 21, 2017 at 9:37 AM Tino Heth via swift-evolution <
swift-evolution at swift.org> wrote:

>
> > Fact is, you can replace every occurrence of "private" with
> "fileprivate", and your source would compile as before, whereas fileprivate
> saves us from a "friend"-keyword.
>
> This is certainly a source-breaking change.  Consider:
>
> struct Foo {
>
>     fileprivate func foo()->String {return "foo" }
>
>     private func foo()->Int {return 2}
>
> }
>
> print("\(Foo().foo())")
>
> Replacing “private” with “fileprivate” here will introduce a compile error.
>
> True indeed… but can we agree that this is just an hypothetic example, and
> no issue that is likely to happen in productive code?
> Or is this actually taken from one of the projects you measured?
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170321/6c33e499/attachment.html>


More information about the swift-evolution mailing list