Skip to content

Update for fileprivate #410

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/Basic/ByteString.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
/// and then convert to a `ByteString` when complete.
public struct ByteString: ArrayLiteralConvertible {
/// The buffer contents.
private var _bytes: [UInt8]
fileprivate var _bytes: [UInt8]

/// Create an empty byte string.
public init() {
Expand Down
10 changes: 5 additions & 5 deletions Sources/Basic/FSProxy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public enum FSProxyError: ErrorProtocol {
case unknownOSError
}

private extension FSProxyError {
fileprivate extension FSProxyError {
init(errno: Int32) {
switch errno {
case libc.EACCES:
Expand Down Expand Up @@ -131,7 +131,7 @@ public extension FSProxy {
}

/// Concrete FSProxy implementation which communicates with the local file system.
private class LocalFS: FSProxy {
fileprivate class LocalFS: FSProxy {
func exists(_ path: String) -> Bool {
return (try? stat(path)) != nil
}
Expand Down Expand Up @@ -268,19 +268,19 @@ private class LocalFS: FSProxy {
//
// FIXME: This class does not yet support concurrent mutation safely.
public class PseudoFS: FSProxy {
private class Node {
fileprivate class Node {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This surprises me, it is certainly the intent that this is private not fileprivate. What required this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember thinking that too. Probably a bogus diagnostic at one point. I'll change it

Copy link
Contributor Author

@CodaFi CodaFi Jun 13, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I remember now. The rule here is the inner scope can refer to private members in the outer scope but not vice-versa. PseudoFS is using Node's members quite a bit.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh, this seems unfortunate for exactly this use case. Declaring it as fileprivate looks wrong... is it possible this indicates a problem in the proposal?

Copy link
Contributor Author

@CodaFi CodaFi Jun 13, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does seem wrong to use file to mean scope especially considering the name of the proposal itself, but it was the name the community settled on 😅

/// The actual node data.
let contents: NodeContents

init(_ contents: NodeContents) {
self.contents = contents
}
}
private enum NodeContents {
fileprivate enum NodeContents {
case File(ByteString)
case Directory(DirectoryContents)
}
private class DirectoryContents {
fileprivate class DirectoryContents {
var entries: [String: Node]

init(entries: [String: Node] = [:]) {
Expand Down
18 changes: 9 additions & 9 deletions Sources/Basic/OutputByteStream.swift
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ extension String: ByteStreamable {
// MARK: Formatted Streaming Output

// Not nested because it is generic.
private struct SeparatedListStreamable<T: ByteStreamable>: ByteStreamable {
fileprivate struct SeparatedListStreamable<T: ByteStreamable>: ByteStreamable {
let items: [T]
let separator: String

Expand All @@ -268,7 +268,7 @@ private struct SeparatedListStreamable<T: ByteStreamable>: ByteStreamable {
}

// Not nested because it is generic.
private struct TransformedSeparatedListStreamable<T>: ByteStreamable {
fileprivate struct TransformedSeparatedListStreamable<T>: ByteStreamable {
let items: [T]
let transform: (T) -> ByteStreamable
let separator: String
Expand All @@ -282,7 +282,7 @@ private struct TransformedSeparatedListStreamable<T>: ByteStreamable {
}

// Not nested because it is generic.
private struct JSONEscapedTransformedStringListStreamable<T>: ByteStreamable {
fileprivate struct JSONEscapedTransformedStringListStreamable<T>: ByteStreamable {
let items: [T]
let transform: (T) -> String

Expand All @@ -302,7 +302,7 @@ public struct Format {
static public func asJSON(_ value: Bool) -> ByteStreamable {
return JSONEscapedBoolStreamable(value: value)
}
private struct JSONEscapedBoolStreamable: ByteStreamable {
fileprivate struct JSONEscapedBoolStreamable: ByteStreamable {
let value: Bool

func write(to stream: OutputByteStream) {
Expand All @@ -314,7 +314,7 @@ public struct Format {
static public func asJSON(_ value: Int) -> ByteStreamable {
return JSONEscapedIntStreamable(value: value)
}
private struct JSONEscapedIntStreamable: ByteStreamable {
fileprivate struct JSONEscapedIntStreamable: ByteStreamable {
let value: Int

func write(to stream: OutputByteStream) {
Expand All @@ -327,7 +327,7 @@ public struct Format {
static public func asJSON(_ value: Double) -> ByteStreamable {
return JSONEscapedDoubleStreamable(value: value)
}
private struct JSONEscapedDoubleStreamable: ByteStreamable {
fileprivate struct JSONEscapedDoubleStreamable: ByteStreamable {
let value: Double

func write(to stream: OutputByteStream) {
Expand All @@ -342,7 +342,7 @@ public struct Format {
static public func asJSON(_ string: String) -> ByteStreamable {
return JSONEscapedStringStreamable(value: string)
}
private struct JSONEscapedStringStreamable: ByteStreamable {
fileprivate struct JSONEscapedStringStreamable: ByteStreamable {
let value: String

func write(to stream: OutputByteStream) {
Expand All @@ -358,7 +358,7 @@ public struct Format {
static public func asJSON(_ items: [String]) -> ByteStreamable {
return JSONEscapedStringListStreamable(items: items)
}
private struct JSONEscapedStringListStreamable: ByteStreamable {
fileprivate struct JSONEscapedStringListStreamable: ByteStreamable {
let items: [String]

func write(to stream: OutputByteStream) {
Expand All @@ -375,7 +375,7 @@ public struct Format {
static public func asJSON(_ items: [String: String]) -> ByteStreamable {
return JSONEscapedDictionaryStreamable(items: items)
}
private struct JSONEscapedDictionaryStreamable: ByteStreamable {
fileprivate struct JSONEscapedDictionaryStreamable: ByteStreamable {
let items: [String: String]

func write(to stream: OutputByteStream) {
Expand Down
10 changes: 5 additions & 5 deletions Sources/Basic/TOML.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public func ==(lhs: TOMLItem, rhs: TOMLItem) -> Bool {
// MARK: Lexer

/// Extensions to check TOML character classes.
private extension UInt8 {
fileprivate extension UInt8 {
/// Check if this is a space.
func isSpace() -> Bool {
return self == UInt8(ascii: " ") || self == UInt8(ascii: "\t")
Expand Down Expand Up @@ -136,8 +136,8 @@ private extension UInt8 {
/// A basic TOML lexer.
///
/// This implementation doesn't yet support multi-line strings.
private struct Lexer {
private enum Token {
fileprivate struct Lexer {
fileprivate enum Token {
/// Any comment.
case comment
/// Any whitespace.
Expand Down Expand Up @@ -355,7 +355,7 @@ extension Lexer.Token : CustomStringConvertible {
}
}

private struct LexerTokenGenerator : IteratorProtocol {
fileprivate struct LexerTokenGenerator : IteratorProtocol {
var lexer: Lexer

mutating func next() -> Lexer.Token? {
Expand Down Expand Up @@ -405,7 +405,7 @@ private func ==(lhs: Lexer.Token, rhs: Lexer.Token) -> Bool {

// MARK: Parser

private struct Parser {
fileprivate struct Parser {
/// The lexer in use.
private var lexer: Lexer

Expand Down
2 changes: 1 addition & 1 deletion Sources/Build/Command.compile(ClangModule).swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import PackageModel
import Utility
import POSIX

private extension ClangModule {
fileprivate extension ClangModule {
func includeFlagsWithExternalModules(_ externalModules: Set<Module>) -> [String] {
var args: [String] = []
for case let dep as ClangModule in dependencies {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Build/describe().swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ private func write(path: String, write: (OutputByteStream) -> Void) throws -> St
return path
}

private struct Targets {
fileprivate struct Targets {
var test = Target(node: "test", cmds: [])
var main = Target(node: "main", cmds: [])

Expand Down
10 changes: 5 additions & 5 deletions Sources/Commands/SwiftBuildTool.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import func POSIX.chdir
/// Additional conformance for our Options type.
extension BuildToolOptions: XcodeprojOptions {}

private enum Mode: Argument, Equatable, CustomStringConvertible {
fileprivate enum Mode: Argument, Equatable, CustomStringConvertible {
case build(Configuration, Toolchain)
case clean(CleanMode)
case usage
Expand Down Expand Up @@ -60,7 +60,7 @@ private enum Mode: Argument, Equatable, CustomStringConvertible {
}
}

private enum BuildToolFlag: Argument {
fileprivate enum BuildToolFlag: Argument {
case xcc(String)
case xld(String)
case xswiftc(String)
Expand Down Expand Up @@ -110,7 +110,7 @@ private enum BuildToolFlag: Argument {
}
}

private class BuildToolOptions: Options {
fileprivate class BuildToolOptions: Options {
var verbosity: Int = 0
var Xcc: [String] = []
var Xld: [String] = []
Expand Down Expand Up @@ -278,7 +278,7 @@ public struct SwiftBuildTool {
}

extension Build.Configuration {
private init(_ rawValue: String?) throws {
fileprivate init(_ rawValue: String?) throws {
switch rawValue?.lowercased() {
case "debug"?:
self = .debug
Expand All @@ -295,7 +295,7 @@ extension Build.Configuration {
enum CleanMode: CustomStringConvertible {
case build, dist

private init(_ rawValue: String?) throws {
fileprivate init(_ rawValue: String?) throws {
switch rawValue?.lowercased() {
case nil, "build"?:
self = .build
Expand Down
6 changes: 3 additions & 3 deletions Sources/Commands/SwiftPackageTool.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import func POSIX.chdir
/// Additional conformance for our Options type.
extension PackageToolOptions: XcodeprojOptions {}

private enum Mode: Argument, Equatable, CustomStringConvertible {
fileprivate enum Mode: Argument, Equatable, CustomStringConvertible {
case doctor
case dumpPackage
case fetch
Expand Down Expand Up @@ -80,7 +80,7 @@ private enum Mode: Argument, Equatable, CustomStringConvertible {
}
}

private enum PackageToolFlag: Argument {
fileprivate enum PackageToolFlag: Argument {
case initMode(String)
case showDepsMode(String)
case inputPath(String)
Expand Down Expand Up @@ -136,7 +136,7 @@ private enum PackageToolFlag: Argument {
}
}

private class PackageToolOptions: Options {
fileprivate class PackageToolOptions: Options {
var initMode: InitMode = InitMode.library
var showDepsMode: ShowDependenciesMode = ShowDependenciesMode.text
var inputPath: String? = nil
Expand Down
8 changes: 4 additions & 4 deletions Sources/Commands/SwiftTestTool.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import Utility
import func POSIX.chdir
import func POSIX.exit

private enum TestError: ErrorProtocol {
fileprivate enum TestError: ErrorProtocol {
case testsExecutableNotFound
}

Expand All @@ -29,7 +29,7 @@ extension TestError: CustomStringConvertible {
}
}

private enum Mode: Argument, Equatable, CustomStringConvertible {
fileprivate enum Mode: Argument, Equatable, CustomStringConvertible {
case usage
case run(String?)

Expand Down Expand Up @@ -59,7 +59,7 @@ private func ==(lhs: Mode, rhs: Mode) -> Bool {
return lhs.description == rhs.description
}

private enum TestToolFlag: Argument {
fileprivate enum TestToolFlag: Argument {
case chdir(String)

init?(argument: String, pop: () -> String?) throws {
Expand Down Expand Up @@ -200,7 +200,7 @@ public struct SwiftTestTool {
}
}

private extension String {
fileprivate extension String {
var isValidTest: Bool {
#if os(OSX)
return isDirectory // ${foo}.xctest is dir on OSX
Expand Down
2 changes: 1 addition & 1 deletion Sources/Commands/init.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import func Utility.fputs
import func Utility.makeDirectories
import struct Utility.Path

private enum InitError: ErrorProtocol {
fileprivate enum InitError: ErrorProtocol {
case manifestAlreadyExists
}

Expand Down
8 changes: 4 additions & 4 deletions Sources/Commands/show-dependencies.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ func dumpDependenciesOf(rootPackage: Package, mode: ShowDependenciesMode) {
}


private protocol DependenciesDumper {
fileprivate protocol DependenciesDumper {
func dump(dependenciesOf: Package)
}


private final class PlainTextDumper: DependenciesDumper {
fileprivate final class PlainTextDumper: DependenciesDumper {
func dump(dependenciesOf rootpkg: Package) {
func recursiveWalk(packages: [Package], prefix: String = "") {
var hanger = prefix + "├── "
Expand Down Expand Up @@ -64,7 +64,7 @@ private final class PlainTextDumper: DependenciesDumper {
}
}

private final class DotDumper: DependenciesDumper {
fileprivate final class DotDumper: DependenciesDumper {
func dump(dependenciesOf rootpkg: Package) {
func recursiveWalk(rootpkg: Package) {
printNode(rootpkg)
Expand Down Expand Up @@ -94,7 +94,7 @@ private final class DotDumper: DependenciesDumper {
}
}

private final class JsonDumper: DependenciesDumper {
fileprivate final class JsonDumper: DependenciesDumper {
func dump(dependenciesOf rootpkg: Package) {

func recursiveWalk(rootpkg: Package, isLast: Bool = true) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Get/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ extension Package: Fetchable {
return manifest.package.dependencies.map{ ($0.url, $0.versionRange) }
}

private var versionString: String.CharacterView {
fileprivate var versionString: String.CharacterView {
return path.basename.characters.dropFirst(name.characters.count + 1)
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/Get/PackagesDirectory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class PackagesDirectory {
}

/// The set of all repositories available within the `Packages` directory, by origin.
private lazy var availableRepositories: [String: Git.Repo] = { [unowned self] in
fileprivate lazy var availableRepositories: [String: Git.Repo] = { [unowned self] in
var result = Dictionary<String, Git.Repo>()
for prefix in walk(self.prefix, recursively: false) {
guard let repo = Git.Repo(path: prefix), origin = repo.origin else { continue } // TODO: Warn user.
Expand Down
6 changes: 3 additions & 3 deletions Sources/PackageLoading/Manifest+parse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ extension PackageDescription.Package.Dependency {
}

extension PackageDescription.SystemPackageProvider {
private static func fromTOML(_ item: TOMLItem) -> PackageDescription.SystemPackageProvider {
fileprivate static func fromTOML(_ item: TOMLItem) -> PackageDescription.SystemPackageProvider {
guard case .table(let table) = item else { fatalError("unexpected item") }
guard case .string(let name)? = table.items["name"] else { fatalError("missing name") }
guard case .string(let value)? = table.items["value"] else { fatalError("missing value") }
Expand All @@ -203,7 +203,7 @@ extension PackageDescription.SystemPackageProvider {
}

extension PackageDescription.Target {
private static func fromTOML(_ item: TOMLItem) -> PackageDescription.Target {
fileprivate static func fromTOML(_ item: TOMLItem) -> PackageDescription.Target {
// This is a private API, currently, so we do not currently try and
// validate the input.
guard case .table(let table) = item else { fatalError("unexpected item") }
Expand All @@ -223,7 +223,7 @@ extension PackageDescription.Target {
}

extension PackageDescription.Target.Dependency {
private static func fromTOML(_ item: TOMLItem) -> PackageDescription.Target.Dependency {
fileprivate static func fromTOML(_ item: TOMLItem) -> PackageDescription.Target.Dependency {
guard case .string(let name) = item else { fatalError("unexpected item") }
return .Target(name: name)
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/PackageLoading/Module+PkgConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ extension ModuleProtocol {
}
}

private extension SystemPackageProvider {
private var installText: String {
fileprivate extension SystemPackageProvider {
fileprivate var installText: String {
switch self {
case .Brew(let name):
return " brew install \(name)\n"
Expand Down
Loading