From 7784824add0fd7a94a65120a697d3fac522503d8 Mon Sep 17 00:00:00 2001 From: Harlan Haskins Date: Wed, 6 Apr 2016 15:27:11 -0700 Subject: [PATCH] [SE-0046] Implemented consistent function labels --- Sources/Build/Buildable.swift | 4 +-- .../Build/Command.compile(ClangModule).swift | 6 ++-- .../Build/Command.compile(SwiftModule).swift | 2 +- Sources/Build/Command.link().swift | 2 +- Sources/Build/Command.swift | 2 +- Sources/Build/YAML.swift | 2 +- Sources/Build/describe().swift | 6 ++-- Sources/Build/misc.swift | 2 +- Sources/Get/Fetchable.swift | 2 +- Sources/Get/Fetcher.swift | 14 ++++---- Sources/Get/Git.swift | 2 +- Sources/Get/Package.swift | 4 +-- Sources/Get/PackagesDirectory.swift | 6 ++-- Sources/Get/RawClone.swift | 2 +- Sources/Get/Version.swift | 2 +- Sources/Get/get().swift | 2 +- Sources/ManifestParser/TOML.swift | 18 +++++------ Sources/ManifestParser/fromTOML().swift | 10 +++--- Sources/Multitool/Error.swift | 6 ++-- Sources/Multitool/OptionsParser.swift | 4 +-- Sources/Multitool/build().swift | 2 +- Sources/POSIX/Error.swift | 2 +- Sources/POSIX/chdir.swift | 2 +- Sources/POSIX/fopen.swift | 2 +- Sources/POSIX/fputs.swift | 2 +- Sources/POSIX/getenv.swift | 2 +- Sources/POSIX/isatty.swift | 2 +- Sources/POSIX/misc.swift | 2 +- Sources/POSIX/mkdir.swift | 4 +-- Sources/POSIX/mkdtemp.swift | 2 +- Sources/POSIX/opendir.swift | 2 +- Sources/POSIX/popen.swift | 4 +-- Sources/POSIX/readlink.swift | 2 +- Sources/POSIX/realpath.swift | 2 +- Sources/POSIX/rename.swift | 2 +- Sources/POSIX/rmdir.swift | 2 +- Sources/POSIX/strftime.swift | 2 +- Sources/POSIX/system.swift | 14 ++++---- Sources/POSIX/unlink.swift | 2 +- Sources/PackageDescription/Package.swift | 10 +++--- Sources/PackageType/Module.swift | 2 +- Sources/PackageType/Package.swift | 2 +- Sources/PackageType/c99name().swift | 2 +- Sources/Transmute/Package+modules.swift | 10 +++--- Sources/Transmute/Package+products.swift | 2 +- .../Package+shouldConsiderDirectory.swift | 2 +- Sources/Transmute/fillModuleGraph().swift | 2 +- Sources/Transmute/sort().swift | 4 +-- Sources/Transmute/transmute().swift | 2 +- Sources/Utility/CollectionExtensions.swift | 6 ++-- Sources/Utility/File.swift | 2 +- Sources/Utility/Git.swift | 4 +-- Sources/Utility/POSIXConvenience.swift | 2 +- Sources/Utility/Path.swift | 12 +++---- Sources/Utility/StringExtensions.swift | 6 ++-- Sources/Utility/URL.swift | 4 +-- Sources/Utility/Verbosity.swift | 20 ++++++------ Sources/Utility/misc.swift | 2 +- Sources/Utility/walk.swift | 4 +-- Sources/Xcodeproj/generate().swift | 4 +-- Sources/Xcodeproj/pbxproj().swift | 2 +- Sources/Xcodeproj/xcscheme().swift | 2 +- Sources/libc/String+Linux.swift | 4 +-- Sources/swift-build/initPackage.swift | 4 +-- Sources/swift-build/main.swift | 4 +-- Sources/swift-build/usage.swift | 2 +- Sources/swift-build/xp.swift | 2 +- Sources/swift-test/test.swift | 2 +- Sources/swift-test/usage.swift | 2 +- Tests/Functional/TestModuleMaps.swift | 4 +-- Tests/Functional/TestValidLayouts.swift | 2 +- Tests/Functional/Utilities.swift | 18 +++++------ Tests/Get/DependencyGraphTests.swift | 32 +++++++++---------- Tests/Get/RawCloneTests.swift | 4 +-- Tests/ManifestParser/ManifestTests.swift | 2 +- Tests/ManifestParser/SerializationTests.swift | 2 +- Tests/ManifestParser/TOMLTests.swift | 6 ++-- Tests/PackageDescription/VersionTests.swift | 2 +- Tests/Transmute/ModuleTests.swift | 2 +- Tests/Utility/CollectionTests.swift | 4 +-- Tests/Utility/FileTests.swift | 2 +- Tests/Utility/StringTests.swift | 2 +- Tests/Xcodeproj/TestGeneration.swift | 4 +-- 83 files changed, 183 insertions(+), 183 deletions(-) diff --git a/Sources/Build/Buildable.swift b/Sources/Build/Buildable.swift index 00c48a806fa..481694114d8 100644 --- a/Sources/Build/Buildable.swift +++ b/Sources/Build/Buildable.swift @@ -18,7 +18,7 @@ protocol Buildable { extension CModule { ///Returns the build directory path of a CModule - func buildDirectory(prefix: String) -> String { + func buildDirectory(_ prefix: String) -> String { return Path.join(prefix, "\(c99name).build") } } @@ -28,7 +28,7 @@ extension Module: Buildable { return self is TestModule } - func XccFlags(prefix: String) -> [String] { + func XccFlags(_ prefix: String) -> [String] { return recursiveDependencies.flatMap { module -> [String] in if let module = module as? ClangModule { ///For ClangModule we check if there is a user provided module map diff --git a/Sources/Build/Command.compile(ClangModule).swift b/Sources/Build/Command.compile(ClangModule).swift index 5825cfd995a..58863161c5b 100644 --- a/Sources/Build/Command.compile(ClangModule).swift +++ b/Sources/Build/Command.compile(ClangModule).swift @@ -22,7 +22,7 @@ private extension ClangModule { return args } - func includeFlagsWithExternalModules(externalModules: Set) -> [String] { + func includeFlagsWithExternalModules(_ externalModules: Set) -> [String] { var args: [String] = [] for case let dep as ClangModule in dependencies { let includeFlag: String @@ -45,7 +45,7 @@ private extension ClangModule { return args } - func optimizationFlags(conf: Configuration) -> [String] { + func optimizationFlags(_ conf: Configuration) -> [String] { switch conf { case .Debug: return ["-g", "-O0"] @@ -56,7 +56,7 @@ private extension ClangModule { } private extension Sources { - func compilePathsForBuildDir(wd: String) -> [(filename: String, source: String, object: String, deps: String)] { + func compilePathsForBuildDir(_ wd: String) -> [(filename: String, source: String, object: String, deps: String)] { return relativePaths.map { source in let path = Path.join(root, source) let object = Path.join(wd, "\(source).o") diff --git a/Sources/Build/Command.compile(SwiftModule).swift b/Sources/Build/Command.compile(SwiftModule).swift index 1ff350092e6..655c6223a1f 100644 --- a/Sources/Build/Command.compile(SwiftModule).swift +++ b/Sources/Build/Command.compile(SwiftModule).swift @@ -16,7 +16,7 @@ extension Command { let otherArgs = otherArgs + module.XccFlags(prefix) - func cmd(tool: ToolProtocol) -> Command { + func cmd(_ tool: ToolProtocol) -> Command { return Command(node: module.targetName, tool: tool) } diff --git a/Sources/Build/Command.link().swift b/Sources/Build/Command.link().swift index 33dcde38bcd..0f59e0502d6 100644 --- a/Sources/Build/Command.link().swift +++ b/Sources/Build/Command.link().swift @@ -17,7 +17,7 @@ import Utility extension Command { - static func link(product: Product, configuration conf: Configuration, prefix: String, otherArgs: [String], SWIFT_EXEC: String) throws -> Command { + static func link(_ product: Product, configuration conf: Configuration, prefix: String, otherArgs: [String], SWIFT_EXEC: String) throws -> Command { let objects: [String] switch conf { diff --git a/Sources/Build/Command.swift b/Sources/Build/Command.swift index 182c5cf9296..a669bfb76a4 100644 --- a/Sources/Build/Command.swift +++ b/Sources/Build/Command.swift @@ -12,7 +12,7 @@ struct Command { let node: String let tool: ToolProtocol - static func createDirectory(path: String) -> Command { + static func createDirectory(_ path: String) -> Command { return Command(node: path, tool: MkdirTool(path: path)) } } diff --git a/Sources/Build/YAML.swift b/Sources/Build/YAML.swift index 55e2027bab4..998d5a1a74c 100644 --- a/Sources/Build/YAML.swift +++ b/Sources/Build/YAML.swift @@ -28,7 +28,7 @@ extension Bool: YAMLRepresentable { extension Array where Element: YAMLRepresentable { var YAML: String { - func quote(input: String) -> String { + func quote(_ input: String) -> String { for c in input.characters { if c == "@" || c == " " || c == "-" || c == "&" { return "\"\(input)\"" diff --git a/Sources/Build/describe().swift b/Sources/Build/describe().swift index 919ce914f0b..9e6a4d41cf9 100644 --- a/Sources/Build/describe().swift +++ b/Sources/Build/describe().swift @@ -18,7 +18,7 @@ import Utility /** - Returns: path to generated YAML for consumption by the llbuild based swift-build-tool */ -public func describe(prefix: String, _ conf: Configuration, _ modules: [Module], _ externalModules: Set, _ products: [Product], Xcc: [String], Xld: [String], Xswiftc: [String], toolchain: Toolchain) throws -> String { +public func describe(_ prefix: String, _ conf: Configuration, _ modules: [Module], _ externalModules: Set, _ products: [Product], Xcc: [String], Xld: [String], Xswiftc: [String], toolchain: Toolchain) throws -> String { guard modules.count > 0 else { throw Error.NoModules @@ -78,7 +78,7 @@ public func describe(prefix: String, _ conf: Configuration, _ modules: [Module], } } -private func write(path path: String, write: ((String) -> Void) -> Void) throws -> String { +private func write(path: String, write: ((String) -> Void) -> Void) throws -> String { var storedError: ErrorProtocol? try fopen(path, mode: .Write) { fp in @@ -105,7 +105,7 @@ private struct Targets { var test = Target(node: "test", cmds: []) var main = Target(node: "default", cmds: []) - mutating func append(command: Command, for buildable: Buildable) { + mutating func append(_ command: Command, for buildable: Buildable) { if buildable.isTest { test.cmds.append(command) } else { diff --git a/Sources/Build/misc.swift b/Sources/Build/misc.swift index 31093440924..58242e9bdf6 100644 --- a/Sources/Build/misc.swift +++ b/Sources/Build/misc.swift @@ -99,7 +99,7 @@ extension ClangModule { } ///warn user if in case module name and c99name are different and there a `name.h` umbrella header - private func diagnoseInvalidUmbrellaHeader(path: String) { + private func diagnoseInvalidUmbrellaHeader(_ path: String) { let umbrellaHeader = Path.join(path, "\(c99name).h") let invalidUmbrellaHeader = Path.join(path, "\(name).h") if c99name != name && invalidUmbrellaHeader.isFile { diff --git a/Sources/Get/Fetchable.swift b/Sources/Get/Fetchable.swift index 108e9118946..7df2ff6bb97 100644 --- a/Sources/Get/Fetchable.swift +++ b/Sources/Get/Fetchable.swift @@ -26,5 +26,5 @@ protocol Fetchable { //FIXME protocols cannot impose new property constraints, // so Package has a version { get } already, we cannot add // a set, so instead we have to have this protocol func - func setVersion(newValue: Version) throws + func setVersion(_ newValue: Version) throws } diff --git a/Sources/Get/Fetcher.swift b/Sources/Get/Fetcher.swift index e36c6f8f7d9..4feff16fc72 100644 --- a/Sources/Get/Fetcher.swift +++ b/Sources/Get/Fetcher.swift @@ -17,11 +17,11 @@ import struct PackageDescription.Version protocol Fetcher { associatedtype T: Fetchable - func find(url url: String) throws -> Fetchable? - func fetch(url url: String) throws -> Fetchable - func finalize(fetchable: Fetchable) throws -> T + func find(url: String) throws -> Fetchable? + func fetch(url: String) throws -> Fetchable + func finalize(_ fetchable: Fetchable) throws -> T - func recursivelyFetch(urls: [(String, Range)]) throws -> [T] + func recursivelyFetch(_ urls: [(String, Range)]) throws -> [T] } extension Fetcher { @@ -30,15 +30,15 @@ extension Fetcher { This is our standard implementation that we override when testing. */ - func recursivelyFetch(urls: [(String, Range)]) throws -> [T] { + func recursivelyFetch(_ urls: [(String, Range)]) throws -> [T] { var graph = [String: (Fetchable, Range)]() - func recurse(urls: [(String, Range)]) throws -> [String] { + func recurse(_ urls: [(String, Range)]) throws -> [String] { return try urls.flatMap { url, specifiedVersionRange -> [String] in - func adjust(pkg: Fetchable, _ versionRange: Range) throws { + func adjust(_ pkg: Fetchable, _ versionRange: Range) throws { guard let v = pkg.constrain(to: versionRange) else { throw Error.InvalidDependencyGraphMissingTag(package: url, requestedTag: "\(versionRange)", existingTags: "\(pkg.availableVersions)") } diff --git a/Sources/Get/Git.swift b/Sources/Get/Git.swift index d894bbb4259..09ba5dd63da 100644 --- a/Sources/Get/Git.swift +++ b/Sources/Get/Git.swift @@ -15,7 +15,7 @@ import enum POSIX.Error import Utility extension Git { - class func clone(url: String, to dstdir: String) throws -> Repo { + class func clone(_ url: String, to dstdir: String) throws -> Repo { // canonicalize URL var url = url if URL.scheme(url) == nil { diff --git a/Sources/Get/Package.swift b/Sources/Get/Package.swift index 8c33d578e24..d67fc2687a2 100644 --- a/Sources/Get/Package.swift +++ b/Sources/Get/Package.swift @@ -15,7 +15,7 @@ import Utility extension Package { // FIXME we *always* have a manifest, don't reparse it - static func make(repo repo: Git.Repo, manifestParser: (path: String, url: String) throws -> Manifest) throws -> Package? { + static func make(repo: Git.Repo, manifestParser: (path: String, url: String) throws -> Manifest) throws -> Package? { guard let origin = repo.origin else { throw Error.NoOrigin(repo.path) } let manifest = try manifestParser(path: repo.path, url: origin) let pkg = Package(manifest: manifest, url: origin) @@ -45,7 +45,7 @@ extension Package: Fetchable { return [version] } - func setVersion(newValue: Version) throws { + func setVersion(_ newValue: Version) throws { throw Get.Error.InvalidDependencyGraph(url) } } diff --git a/Sources/Get/PackagesDirectory.swift b/Sources/Get/PackagesDirectory.swift index 735ff71630b..9202c76e806 100644 --- a/Sources/Get/PackagesDirectory.swift +++ b/Sources/Get/PackagesDirectory.swift @@ -30,7 +30,7 @@ class PackagesDirectory { extension PackagesDirectory: Fetcher { typealias T = Package - func find(url url: String) throws -> Fetchable? { + func find(url: String) throws -> Fetchable? { for prefix in walk(self.prefix, recursively: false) { guard let repo = Git.Repo(path: prefix) else { continue } //TODO warn user guard repo.origin == url else { continue } @@ -39,7 +39,7 @@ extension PackagesDirectory: Fetcher { return nil } - func fetch(url url: String) throws -> Fetchable { + func fetch(url: String) throws -> Fetchable { let dstdir = Path.join(prefix, Package.nameForURL(url)) if let repo = Git.Repo(path: dstdir) where repo.origin == url { //TODO need to canonicalize the URL need URL struct @@ -52,7 +52,7 @@ extension PackagesDirectory: Fetcher { return try RawClone(path: dstdir, manifestParser: manifestParser) } - func finalize(fetchable: Fetchable) throws -> Package { + func finalize(_ fetchable: Fetchable) throws -> Package { switch fetchable { case let clone as RawClone: let prefix = Path.join(self.prefix, clone.finalName) diff --git a/Sources/Get/RawClone.swift b/Sources/Get/RawClone.swift index a86d44c9923..f7abf648c12 100644 --- a/Sources/Get/RawClone.swift +++ b/Sources/Get/RawClone.swift @@ -60,7 +60,7 @@ class RawClone: Fetchable { } /// contract, you cannot call this before you have attempted to `constrain` this clone - func setVersion(ver: Version) throws { + func setVersion(_ ver: Version) throws { let packageVersionsArePrefixed = repo.versionsArePrefixed let v = (packageVersionsArePrefixed ? "v" : "") + ver.description try Git.runPopen([Git.tool, "-C", path, "reset", "--hard", v]) diff --git a/Sources/Get/Version.swift b/Sources/Get/Version.swift index 7c1c2128178..0a376986249 100644 --- a/Sources/Get/Version.swift +++ b/Sources/Get/Version.swift @@ -24,7 +24,7 @@ extension Version { return self.min.. Version? { + static func vprefix(_ string: String.CharacterView) -> Version? { if string.first == "v" { return Version(string.dropFirst()) } else { diff --git a/Sources/Get/get().swift b/Sources/Get/get().swift index 0c0919dbc07..cd250143535 100644 --- a/Sources/Get/get().swift +++ b/Sources/Get/get().swift @@ -17,7 +17,7 @@ import Utility - Throws: Error.InvalidDependencyGraph - Returns: The modules that this manifest requires building */ -public func get(manifest: Manifest, manifestParser: (path: String, url: String) throws -> Manifest) throws -> (rootPackage: Package, externalPackages:[Package]) { +public func get(_ manifest: Manifest, manifestParser: (path: String, url: String) throws -> Manifest) throws -> (rootPackage: Package, externalPackages:[Package]) { let dir = Path.join(manifest.path.parentDirectory, "Packages") let box = PackagesDirectory(prefix: dir, manifestParser: manifestParser) diff --git a/Sources/ManifestParser/TOML.swift b/Sources/ManifestParser/TOML.swift index e6158baa295..86d2a999233 100644 --- a/Sources/ManifestParser/TOML.swift +++ b/Sources/ManifestParser/TOML.swift @@ -467,7 +467,7 @@ private struct Parser { } /// Find the new table to insert into given the top-level table and a list of specifiers. - private mutating func findInsertPoint(topLevelTable: TOMLItemTable, _ specifiers: [String], isAppend: Bool, startToken: Lexer.Token) -> TOMLItemTable { + private mutating func findInsertPoint(_ topLevelTable: TOMLItemTable, _ specifiers: [String], isAppend: Bool, startToken: Lexer.Token) -> TOMLItemTable { // FIXME: Handle TOML requirements (sole definition). var into = topLevelTable for (i,specifier) in specifiers.enumerated() { @@ -517,7 +517,7 @@ private struct Parser { /// item), including the terminating brackets. /// /// - Parameter isAppend: Whether the specifier should end with double brackets. - private mutating func parseTableSpecifier(isAppend: Bool) -> [String]? { + private mutating func parseTableSpecifier(_ isAppend: Bool) -> [String]? { let startToken = lookahead // Parse all of the specifiers. @@ -573,7 +573,7 @@ private struct Parser { // MARK: Parser Implementation /// Report an error at the given token. - private mutating func error(message: String, at: Lexer.Token) { + private mutating func error(_ message: String, at: Lexer.Token) { errors.append(message) } @@ -588,7 +588,7 @@ private struct Parser { } /// Consume a token if it matches a particular block. - private mutating func consumeIf(match: (Lexer.Token) -> Bool) -> Bool { + private mutating func consumeIf(_ match: (Lexer.Token) -> Bool) -> Bool { if match(lookahead) { eat() return true @@ -610,7 +610,7 @@ private struct Parser { } /// Parse the contents of a table, stopping at the next table marker. - private mutating func parseTableContents(table: TOMLItemTable) { + private mutating func parseTableContents(_ table: TOMLItemTable) { // Parse assignments until we reach the EOF or a new table record. while lookahead != .EOF && lookahead != .LSquare { // If we have a bare newline, ignore it. @@ -624,7 +624,7 @@ private struct Parser { } /// Parse an individual table assignment. - private mutating func parseAssignment(table: TOMLItemTable) { + private mutating func parseAssignment(_ table: TOMLItemTable) { // Parse the LHS. let key: String switch eat() { @@ -727,7 +727,7 @@ private struct Parser { return .Array(contents: array) } - private func parseNumberItem(spelling: String) -> TOMLItem? { + private func parseNumberItem(_ spelling: String) -> TOMLItem? { let normalized = String(spelling.characters.filter { $0 != "_" }) @@ -749,7 +749,7 @@ public struct TOMLParsingError : ErrorProtocol { /// Public interface to parsing TOML. public extension TOMLItem { - static func parse(data: Swift.String) throws -> TOMLItem { + static func parse(_ data: Swift.String) throws -> TOMLItem { // Parse the string. var parser = Parser(data) let result = parser.parse() @@ -768,7 +768,7 @@ public extension TOMLItem { /// Internal function for testing the lexer. /// /// returns: A list of the lexed tokens' string representations. -internal func lexTOML(data: String) -> [String] { +internal func lexTOML(_ data: String) -> [String] { let lexer = Lexer(data) return lexer.map { String($0) } } diff --git a/Sources/ManifestParser/fromTOML().swift b/Sources/ManifestParser/fromTOML().swift index 79768ba5c6a..c4f99b2921f 100644 --- a/Sources/ManifestParser/fromTOML().swift +++ b/Sources/ManifestParser/fromTOML().swift @@ -12,7 +12,7 @@ import Utility import PackageDescription extension PackageDescription.Package { - public static func fromTOML(item: TOMLItem, baseURL: String? = nil) -> PackageDescription.Package { + public static func fromTOML(_ item: TOMLItem, baseURL: String? = nil) -> PackageDescription.Package { // This is a private API, currently, so we do not currently try and // validate the input. guard case .Table(let topLevelTable) = item else { fatalError("unexpected item") } @@ -61,7 +61,7 @@ extension PackageDescription.Package { } extension PackageDescription.Package.Dependency { - public static func fromTOML(item: TOMLItem, baseURL: String?) -> PackageDescription.Package.Dependency { + public static func fromTOML(_ item: TOMLItem, baseURL: String?) -> PackageDescription.Package.Dependency { guard case .Array(let array) = item where array.items.count == 3 else { fatalError("Unexpected TOMLItem") } @@ -86,7 +86,7 @@ extension PackageDescription.Package.Dependency { } extension PackageDescription.Target { - private static func fromTOML(item: TOMLItem) -> PackageDescription.Target { + private 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") } @@ -106,7 +106,7 @@ extension PackageDescription.Target { } extension PackageDescription.Target.Dependency { - private static func fromTOML(item: TOMLItem) -> PackageDescription.Target.Dependency { + private static func fromTOML(_ item: TOMLItem) -> PackageDescription.Target.Dependency { guard case .String(let name) = item else { fatalError("unexpected item") } return .Target(name: name) } @@ -142,7 +142,7 @@ extension PackageDescription.Product { self.init(name: name, type: type, modules: modules) } - public static func fromTOML(item: TOMLItem) -> [PackageDescription.Product] { + public static func fromTOML(_ item: TOMLItem) -> [PackageDescription.Product] { guard case .Table(let root) = item else { fatalError("unexpected item") } guard let productsItem = root.items["products"] else { return [] } guard case .Array(let array) = productsItem else { fatalError("products wrong type") } diff --git a/Sources/Multitool/Error.swift b/Sources/Multitool/Error.swift index ac6b1feb7e8..bc5a969d80f 100644 --- a/Sources/Multitool/Error.swift +++ b/Sources/Multitool/Error.swift @@ -55,7 +55,7 @@ extension Error: CustomStringConvertible { } } -@noreturn public func handleError(msg: Any, usage: ((String) -> Void) -> Void) { +@noreturn public func handleError(_ msg: Any, usage: ((String) -> Void) -> Void) { switch msg { case CommandLineError.InvalidUsage(let hint, let mode): print(error: "invalid usage: \(hint)") @@ -77,14 +77,14 @@ extension Error: CustomStringConvertible { exit(1) } -private func red(input: Any) -> String { +private func red(_ input: Any) -> String { let input = "\(input)" let ESC = "\u{001B}" let CSI = "\(ESC)[" return CSI + "31m" + input + CSI + "0m" } -private func print(error error: Any) { +private func print(error: Any) { if !isatty(fileno(libc.stderr)) { let cmd = Process.arguments.first?.basename ?? "SwiftPM" print("\(cmd): error:", error, to: &stderr) diff --git a/Sources/Multitool/OptionsParser.swift b/Sources/Multitool/OptionsParser.swift index cb47e516106..715b42475ab 100644 --- a/Sources/Multitool/OptionsParser.swift +++ b/Sources/Multitool/OptionsParser.swift @@ -16,7 +16,7 @@ public protocol ModeArgument: Argument, Equatable, CustomStringConvertible { } -public func parse(arguments arguments: [String]) throws -> (Mode?, [Flag]) { +public func parse(arguments: [String]) throws -> (Mode?, [Flag]) { var mode: Mode! var it = arguments.makeIterator() @@ -58,7 +58,7 @@ public func parse(arguments arguments: [Stri return (mode, flags) } -private func split(arg: String) -> (String, String?) { +private func split(_ arg: String) -> (String, String?) { let chars = arg.characters if let ii = chars.index(of: "=") { let flag = chars.prefix(upTo: ii) diff --git a/Sources/Multitool/build().swift b/Sources/Multitool/build().swift index 11ea75347b5..ab54b0fbbfd 100644 --- a/Sources/Multitool/build().swift +++ b/Sources/Multitool/build().swift @@ -13,7 +13,7 @@ import PackageType import Utility import func libc.exit -public func build(YAMLPath YAMLPath: String, target: String) throws { +public func build(YAMLPath: String, target: String) throws { do { var args = [llbuild, "-f", YAMLPath, target] if verbosity != .Concise { args.append("-v") } diff --git a/Sources/POSIX/Error.swift b/Sources/POSIX/Error.swift index f9bab27f676..b3cebabbc26 100644 --- a/Sources/POSIX/Error.swift +++ b/Sources/POSIX/Error.swift @@ -45,7 +45,7 @@ import func libc.strerror extension SystemError: CustomStringConvertible { public var description: String { - func strerror(errno: Int32) -> String { + func strerror(_ errno: Int32) -> String { let cmsg = libc.strerror(errno) let msg = String(validatingUTF8: cmsg) ?? "Unknown Error" return "\(msg) (\(errno))" diff --git a/Sources/POSIX/chdir.swift b/Sources/POSIX/chdir.swift index d2d85214e18..006016cbe29 100644 --- a/Sources/POSIX/chdir.swift +++ b/Sources/POSIX/chdir.swift @@ -21,7 +21,7 @@ public var argv0: String { /** Causes the named directory to become the current working directory. */ -public func chdir(path: String) throws { +public func chdir(_ path: String) throws { if _argv0 == nil { _argv0 = try realpath(Process.arguments.first!) } guard libc.chdir(path) == 0 else { diff --git a/Sources/POSIX/fopen.swift b/Sources/POSIX/fopen.swift index 10bb5de6d0d..407eeb55f35 100644 --- a/Sources/POSIX/fopen.swift +++ b/Sources/POSIX/fopen.swift @@ -17,7 +17,7 @@ public enum FopenMode: String { case Write = "w" } -public func fopen(path: String, mode: FopenMode = .Read) throws -> UnsafeMutablePointer { +public func fopen(_ path: String, mode: FopenMode = .Read) throws -> UnsafeMutablePointer { let f = libc.fopen(path, mode.rawValue) guard f != nil else { throw SystemError.fopen(errno, path) } return f diff --git a/Sources/POSIX/fputs.swift b/Sources/POSIX/fputs.swift index 1640652d8e3..2debb71f4d3 100644 --- a/Sources/POSIX/fputs.swift +++ b/Sources/POSIX/fputs.swift @@ -12,7 +12,7 @@ import struct libc.FILE import func libc.fputs import var libc.EOF -public func fputs(string: String, _ fp: UnsafeMutablePointer) throws { +public func fputs(_ string: String, _ fp: UnsafeMutablePointer) throws { guard libc.fputs(string, fp) != EOF else { throw SystemError.fputs } diff --git a/Sources/POSIX/getenv.swift b/Sources/POSIX/getenv.swift index 2c0de634a7e..3fa1d364061 100644 --- a/Sources/POSIX/getenv.swift +++ b/Sources/POSIX/getenv.swift @@ -10,7 +10,7 @@ import func libc.getenv -public func getenv(key: String) -> String? { +public func getenv(_ key: String) -> String? { let out = libc.getenv(key) return out == nil ? nil : String(validatingUTF8: out) //FIXME locale may not be UTF8 } diff --git a/Sources/POSIX/isatty.swift b/Sources/POSIX/isatty.swift index 1b25ec35f4c..4a80a0a4a9d 100644 --- a/Sources/POSIX/isatty.swift +++ b/Sources/POSIX/isatty.swift @@ -10,6 +10,6 @@ import func libc.isatty -public func isatty(fildes: Int32) -> Bool { +public func isatty(_ fildes: Int32) -> Bool { return libc.isatty(fildes) != 0 } diff --git a/Sources/POSIX/misc.swift b/Sources/POSIX/misc.swift index 2997121fcea..cf57f104d14 100644 --- a/Sources/POSIX/misc.swift +++ b/Sources/POSIX/misc.swift @@ -13,6 +13,6 @@ popen(), returns a pretty-printed string that is user-readable and could be typed into a Terminal to re-attempt execution. */ -public func prettyArguments(args: [String]) -> String { +public func prettyArguments(_ args: [String]) -> String { return args.map { $0.characters.split(separator: " ").map(String.init).joined(separator: "\\ ") }.joined(separator: " ") } diff --git a/Sources/POSIX/mkdir.swift b/Sources/POSIX/mkdir.swift index a446969277e..d8b9d5cea38 100644 --- a/Sources/POSIX/mkdir.swift +++ b/Sources/POSIX/mkdir.swift @@ -20,11 +20,11 @@ import var libc.S_IRWXO It is *not* an error if the directory already exists. */ -public func mkdir(path: String...) throws -> String { +public func mkdir(_ path: String...) throws -> String { return try mkdir(path) } -public func mkdir(path: [String]) throws -> String { +public func mkdir(_ path: [String]) throws -> String { let parts = path.flatMap{ $0.characters.split(separator: "/") } var prefix = path.first!.hasPrefix("/") ? "" diff --git a/Sources/POSIX/mkdtemp.swift b/Sources/POSIX/mkdtemp.swift index cb5b460bdde..13ee5b95b05 100644 --- a/Sources/POSIX/mkdtemp.swift +++ b/Sources/POSIX/mkdtemp.swift @@ -18,7 +18,7 @@ import func libc.rmdir - Note: We only call rmdir() on the directory once done, it is up to you to recursively delete the contents and thus ensure the rmdir succeeds */ -public func mkdtemp(template: String, prefix: String! = nil, @noescape body: (String) throws -> T) rethrows -> T { +public func mkdtemp(_ template: String, prefix: String! = nil, @noescape body: (String) throws -> T) rethrows -> T { var prefix = prefix if prefix == nil { prefix = getenv("TMPDIR") ?? "/tmp/" } if !prefix.hasSuffix("/") { diff --git a/Sources/POSIX/opendir.swift b/Sources/POSIX/opendir.swift index 63823309c41..6ba57e90c2b 100644 --- a/Sources/POSIX/opendir.swift +++ b/Sources/POSIX/opendir.swift @@ -12,7 +12,7 @@ import struct libc.DirHandle import var libc.errno import func libc.opendir -public func opendir(path: String) throws -> DirHandle { +public func opendir(_ path: String) throws -> DirHandle { let d = libc.opendir(path) guard d != nil else { throw SystemError.opendir(errno, path) } return d diff --git a/Sources/POSIX/popen.swift b/Sources/POSIX/popen.swift index 116fb2a362d..0a1f1217587 100644 --- a/Sources/POSIX/popen.swift +++ b/Sources/POSIX/popen.swift @@ -10,7 +10,7 @@ import libc -public func popen(arguments: [String], redirectStandardError: Bool = false, environment: [String: String] = [:]) throws -> String +public func popen(_ arguments: [String], redirectStandardError: Bool = false, environment: [String: String] = [:]) throws -> String { var out = "" try popen(arguments, redirectStandardError: redirectStandardError, environment: environment) { line in @@ -19,7 +19,7 @@ public func popen(arguments: [String], redirectStandardError: Bool = false, envi return out } -public func popen(arguments: [String], redirectStandardError: Bool = false, environment: [String: String] = [:], body: String -> Void) throws +public func popen(_ arguments: [String], redirectStandardError: Bool = false, environment: [String: String] = [:], body: String -> Void) throws { do { // Create a pipe to use for reading the result. diff --git a/Sources/POSIX/readlink.swift b/Sources/POSIX/readlink.swift index 16cafdbc41b..d8b2de11537 100644 --- a/Sources/POSIX/readlink.swift +++ b/Sources/POSIX/readlink.swift @@ -12,7 +12,7 @@ import var libc.errno import var libc.PATH_MAX import func libc.readlink -public func readlink(path: String) throws -> String { +public func readlink(_ path: String) throws -> String { let N = Int(PATH_MAX) let mem = UnsafeMutablePointer(allocatingCapacity: N + 1) let n = readlink(path, mem, N) diff --git a/Sources/POSIX/realpath.swift b/Sources/POSIX/realpath.swift index 1e6b3acb5ba..78a6ba75029 100644 --- a/Sources/POSIX/realpath.swift +++ b/Sources/POSIX/realpath.swift @@ -21,7 +21,7 @@ import func libc.realpath pathname. All components in the provided input must exist when realpath() is called. */ -public func realpath(path: String) throws -> String { +public func realpath(_ path: String) throws -> String { let rv = realpath(path, nil) guard rv != nil else { throw SystemError.realpath(errno, path) } defer { free(rv) } diff --git a/Sources/POSIX/rename.swift b/Sources/POSIX/rename.swift index ae6384c721d..f7642becf96 100644 --- a/Sources/POSIX/rename.swift +++ b/Sources/POSIX/rename.swift @@ -11,7 +11,7 @@ import var libc.errno import func libc.rename -public func rename(old old: String, new: String) throws { +public func rename(old: String, new: String) throws { let rv = libc.rename(old, new) guard rv == 0 else { throw SystemError.rename(errno, old: old, new: new) } } diff --git a/Sources/POSIX/rmdir.swift b/Sources/POSIX/rmdir.swift index 1b028c60795..75175978109 100644 --- a/Sources/POSIX/rmdir.swift +++ b/Sources/POSIX/rmdir.swift @@ -12,7 +12,7 @@ import var libc.errno import func libc.rmdir -public func rmdir(path: String) throws { +public func rmdir(_ path: String) throws { guard rmdir(path) == 0 else { throw SystemError.rmdir(errno, path) } diff --git a/Sources/POSIX/strftime.swift b/Sources/POSIX/strftime.swift index 792cde7b95f..d1309be0d08 100644 --- a/Sources/POSIX/strftime.swift +++ b/Sources/POSIX/strftime.swift @@ -11,7 +11,7 @@ import func libc.strftime import struct libc.tm -public func strftime(format: String, time: tm) throws -> String { +public func strftime(_ format: String, time: tm) throws -> String { let resultSize = format.characters.count + 200 let result = UnsafeMutablePointer(allocatingCapacity: resultSize) defer { diff --git a/Sources/POSIX/system.swift b/Sources/POSIX/system.swift index 90dc017dfb9..e59821200b2 100644 --- a/Sources/POSIX/system.swift +++ b/Sources/POSIX/system.swift @@ -16,7 +16,7 @@ import libc the tool. Uses PATH to find the tool if the first argument path is not absolute. */ -public func system(args: String...) throws { +public func system(_ args: String...) throws { try system(args) } @@ -25,7 +25,7 @@ public func system(args: String...) throws { the tool. Uses PATH to find the tool if the first argument path is not absolute. */ -public func system(arguments: [String], environment: [String:String] = [:]) throws { +public func system(_ arguments: [String], environment: [String:String] = [:]) throws { // make sure subprocess output doesn't get interleaved with our own fflush(stdout) @@ -44,7 +44,7 @@ public func system() {} /// Convenience wrapper for posix_spawn. -func posix_spawnp(path: String, args: [String], environment: [String: String] = [:], fileActions: posix_spawn_file_actions_t? = nil) throws -> pid_t { +func posix_spawnp(_ path: String, args: [String], environment: [String: String] = [:], fileActions: posix_spawn_file_actions_t? = nil) throws -> pid_t { let argv = args.map{ $0.withCString(strdup) } defer { for arg in argv { free(arg) } } @@ -78,21 +78,21 @@ func posix_spawnp(path: String, args: [String], environment: [String: String] = } -private func _WSTATUS(status: CInt) -> CInt { +private func _WSTATUS(_ status: CInt) -> CInt { return status & 0x7f } -private func WIFEXITED(status: CInt) -> Bool { +private func WIFEXITED(_ status: CInt) -> Bool { return _WSTATUS(status) == 0 } -private func WEXITSTATUS(status: CInt) -> CInt { +private func WEXITSTATUS(_ status: CInt) -> CInt { return (status >> 8) & 0xff } /// convenience wrapper for waitpid -func waitpid(pid: pid_t) throws -> Int32 { +func waitpid(_ pid: pid_t) throws -> Int32 { while true { var exitStatus: Int32 = 0 let rv = waitpid(pid, &exitStatus, 0) diff --git a/Sources/POSIX/unlink.swift b/Sources/POSIX/unlink.swift index bb473b25b80..12c33e46413 100644 --- a/Sources/POSIX/unlink.swift +++ b/Sources/POSIX/unlink.swift @@ -12,7 +12,7 @@ import func libc.unlink import var libc.errno -public func unlink(path: String) throws { +public func unlink(_ path: String) throws { guard libc.unlink(path) == 0 else { throw SystemError.unlink(errno, path) } diff --git a/Sources/PackageDescription/Package.swift b/Sources/PackageDescription/Package.swift index 80180930f4e..3ff921eab8d 100644 --- a/Sources/PackageDescription/Package.swift +++ b/Sources/PackageDescription/Package.swift @@ -26,16 +26,16 @@ public final class Package { self.versionRange = versionRange } - public class func Package(url url: String, versions: Range) -> Dependency { + public class func Package(url: String, versions: Range) -> Dependency { return Dependency(url, versions) } - public class func Package(url url: String, majorVersion: Int) -> Dependency { + public class func Package(url: String, majorVersion: Int) -> Dependency { return Dependency(url, Version(majorVersion, 0, 0).. Dependency { + public class func Package(url: String, majorVersion: Int, minor: Int) -> Dependency { return Dependency(url, Version(majorVersion, minor, 0).. Dependency { + public class func Package(url: String, _ version: Version) -> Dependency { return Dependency(url, version...version) } } @@ -130,7 +130,7 @@ public func ==(lhs: Package.Dependency, rhs: Package.Dependency) -> Bool { // MARK: Package Dumping private var dumpInfo: (package: Package, fileNo: Int32)? = nil -private func dumpPackageAtExit(package: Package, fileNo: Int32) { +private func dumpPackageAtExit(_ package: Package, fileNo: Int32) { func dump() { guard let dumpInfo = dumpInfo else { return } let fd = fdopen(dumpInfo.fileNo, "w") diff --git a/Sources/PackageType/Module.swift b/Sources/PackageType/Module.swift index 5ab53cd568a..ee967be23f4 100644 --- a/Sources/PackageType/Module.swift +++ b/Sources/PackageType/Module.swift @@ -170,7 +170,7 @@ extension Module: CustomStringConvertible { // } //} -public func recursiveDependencies(modules: [Module]) -> [Module] { +public func recursiveDependencies(_ modules: [Module]) -> [Module] { var stack = modules var set = Set() var rv = [Module]() diff --git a/Sources/PackageType/Package.swift b/Sources/PackageType/Package.swift index a867cecf75c..c3aa4440c3b 100644 --- a/Sources/PackageType/Package.swift +++ b/Sources/PackageType/Package.swift @@ -47,7 +47,7 @@ public func ==(lhs: Package, rhs: Package) -> Bool { } extension Package { - public static func nameForURL(url: String) -> String { + public static func nameForURL(_ url: String) -> String { let base = url.basename switch URL.scheme(url) ?? "" { diff --git a/Sources/PackageType/c99name().swift b/Sources/PackageType/c99name().swift index 9d6017e38d2..18407c9ec25 100644 --- a/Sources/PackageType/c99name().swift +++ b/Sources/PackageType/c99name().swift @@ -11,7 +11,7 @@ /** Removes characters from name that are invalid in C99 module-names. */ -func c99name(name name: String) -> String { +func c99name(name: String) -> String { var mapped = name.unicodeScalars.filter { switch $0.value { case// a-z A-Z 0-9 _ diff --git a/Sources/Transmute/Package+modules.swift b/Sources/Transmute/Package+modules.swift index 94e7d895f0d..dec17abebea 100644 --- a/Sources/Transmute/Package+modules.swift +++ b/Sources/Transmute/Package+modules.swift @@ -54,7 +54,7 @@ extension Package { } } - func moduleForName(name: String) -> Module? { + func moduleForName(_ name: String) -> Module? { return modules.pick{ $0.name == name } } @@ -75,7 +75,7 @@ extension Package { return modules } - func modulify(path: String, name: String) throws -> Module { + func modulify(_ path: String, name: String) throws -> Module { let walked = walk(path, recursing: shouldConsiderDirectory).map{ $0 } let cSources = walked.filter{ isValidSource($0, validExtensions: Sources.validCExtensions) } @@ -90,11 +90,11 @@ extension Package { return SwiftModule(name: name, sources: Sources(paths: swiftSources, root: path)) } - func isValidSource(path: String) -> Bool { + func isValidSource(_ path: String) -> Bool { return isValidSource(path, validExtensions: Sources.validExtensions) } - func isValidSource(path: String, validExtensions: Set) -> Bool { + func isValidSource(_ path: String, validExtensions: Set) -> Bool { if path.basename.hasPrefix(".") { return false } let path = path.normpath if path == manifest.path.normpath { return false } @@ -104,7 +104,7 @@ extension Package { return validExtensions.contains(ext) } - private func targetForName(name: String) -> Target? { + private func targetForName(_ name: String) -> Target? { return manifest.package.targets.pick{ $0.name == name } } } diff --git a/Sources/Transmute/Package+products.swift b/Sources/Transmute/Package+products.swift index 67202e4c454..cd17aba9645 100644 --- a/Sources/Transmute/Package+products.swift +++ b/Sources/Transmute/Package+products.swift @@ -12,7 +12,7 @@ import PackageType import Utility extension Package { - func products(allModules: [Module]) throws -> [Product] { + func products(_ allModules: [Module]) throws -> [Product] { var products = [Product]() diff --git a/Sources/Transmute/Package+shouldConsiderDirectory.swift b/Sources/Transmute/Package+shouldConsiderDirectory.swift index caf46eb4b56..e158c262e14 100644 --- a/Sources/Transmute/Package+shouldConsiderDirectory.swift +++ b/Sources/Transmute/Package+shouldConsiderDirectory.swift @@ -12,7 +12,7 @@ import PackageType import Utility extension Package { - func shouldConsiderDirectory(path: String) -> Bool { + func shouldConsiderDirectory(_ path: String) -> Bool { let base = path.basename.lowercased() if base == "tests" { return false } if base == "include" { return false } diff --git a/Sources/Transmute/fillModuleGraph().swift b/Sources/Transmute/fillModuleGraph().swift index ebd962c8e27..053fed501d6 100644 --- a/Sources/Transmute/fillModuleGraph().swift +++ b/Sources/Transmute/fillModuleGraph().swift @@ -10,7 +10,7 @@ import PackageType -func fillModuleGraph(packages: [Package], modulesForPackage: (Package) -> [Module]) { +func fillModuleGraph(_ packages: [Package], modulesForPackage: (Package) -> [Module]) { for package in packages { let packageModules = modulesForPackage(package) for dep in package.recursiveDependencies { diff --git a/Sources/Transmute/sort().swift b/Sources/Transmute/sort().swift index 1753a4ecf13..3a10e1c1ee0 100644 --- a/Sources/Transmute/sort().swift +++ b/Sources/Transmute/sort().swift @@ -13,10 +13,10 @@ import PackageType /** Depth-first topological sort of target dependencies. */ -func sort(module: Module) { +func sort(_ module: Module) { var visited = Set() - func recurse(module: Module) -> [Module] { + func recurse(_ module: Module) -> [Module] { return module.dependencies.flatMap { dep -> [Module] in if visited.contains(dep) { return [] diff --git a/Sources/Transmute/transmute().swift b/Sources/Transmute/transmute().swift index 7bcd02babaa..95a0b1f6b4f 100644 --- a/Sources/Transmute/transmute().swift +++ b/Sources/Transmute/transmute().swift @@ -12,7 +12,7 @@ import PackageType import Utility import func libc.exit -public func transmute(rootPackage: Package, externalPackages: [Package]) throws -> (modules: [Module], externalModules: [Module], products: [Product]) { +public func transmute(_ rootPackage: Package, externalPackages: [Package]) throws -> (modules: [Module], externalModules: [Module], products: [Product]) { var products: [Product] = [] var map: [Package: [Module]] = [:] diff --git a/Sources/Utility/CollectionExtensions.swift b/Sources/Utility/CollectionExtensions.swift index dfea9c832a5..d1817fe2ed2 100644 --- a/Sources/Utility/CollectionExtensions.swift +++ b/Sources/Utility/CollectionExtensions.swift @@ -10,7 +10,7 @@ extension Collection { - public func pick(body: (Iterator.Element) -> Bool) -> Iterator.Element? { + public func pick(_ body: (Iterator.Element) -> Bool) -> Iterator.Element? { for x in self where body(x) { return x } @@ -30,7 +30,7 @@ extension Collection { return (t, u) } - public func partition(body: (Iterator.Element) -> Bool) -> ([Iterator.Element], [Iterator.Element]) { + public func partition(_ body: (Iterator.Element) -> Bool) -> ([Iterator.Element], [Iterator.Element]) { var a: [Iterator.Element] = [] var b: [Iterator.Element] = [] for e in self { @@ -47,7 +47,7 @@ extension Collection { extension Collection where Iterator.Element : Equatable { /// Split around a delimiting subsequence with maximum number of splits == 2 - func splitAround(delimiter: [Iterator.Element]) -> ([Iterator.Element], [Iterator.Element]?) { + func splitAround(_ delimiter: [Iterator.Element]) -> ([Iterator.Element], [Iterator.Element]?) { let orig = Array(self) let end = orig.endIndex diff --git a/Sources/Utility/File.swift b/Sources/Utility/File.swift index 376f5b43ea3..f47b985e325 100644 --- a/Sources/Utility/File.swift +++ b/Sources/Utility/File.swift @@ -38,7 +38,7 @@ public struct File { In the event of read-error we do not feed a partially generated line before ending iteration. */ - public func enumerate(separator: Character = "\n") throws -> FileLineGenerator { + public func enumerate(_ separator: Character = "\n") throws -> FileLineGenerator { return try FileLineGenerator(path: path, separator: separator) } } diff --git a/Sources/Utility/Git.swift b/Sources/Utility/Git.swift index 8edecc811ec..30e76f4ad27 100644 --- a/Sources/Utility/Git.swift +++ b/Sources/Utility/Git.swift @@ -74,7 +74,7 @@ public class Git { return Int(String(first)) } - @noreturn public class func handle(error: ErrorProtocol) { + @noreturn public class func handle(_ error: ErrorProtocol) { // Git 2.0 or higher is required if Git.majorVersionNumber < 2 { print("error: ", Error.ObsoleteGitVersion) @@ -84,7 +84,7 @@ public class Git { exit(1) } - public class func runPopen(arguments: [String]) throws -> String { + public class func runPopen(_ arguments: [String]) throws -> String { do { return try popen(arguments) } catch let error { diff --git a/Sources/Utility/POSIXConvenience.swift b/Sources/Utility/POSIXConvenience.swift index b70487548cd..2a53ebf9222 100644 --- a/Sources/Utility/POSIXConvenience.swift +++ b/Sources/Utility/POSIXConvenience.swift @@ -10,7 +10,7 @@ import POSIX -public func fopen(path: String..., mode: FopenMode = .Read, body: (UnsafeMutablePointer) throws -> Void) throws { +public func fopen(_ path: String..., mode: FopenMode = .Read, body: (UnsafeMutablePointer) throws -> Void) throws { var fp = try POSIX.fopen(Path.join(path), mode: mode) defer { if fp != nil { fclose(fp) } } try body(fp) diff --git a/Sources/Utility/Path.swift b/Sources/Utility/Path.swift index 8084e4db8b1..1123cf4d921 100644 --- a/Sources/Utility/Path.swift +++ b/Sources/Utility/Path.swift @@ -24,12 +24,12 @@ public struct Path { future we support platforms that have a different separator we will convert any "/" characters in your strings to the platform separator. */ - public static func join(components: String...) -> String { + public static func join(_ components: String...) -> String { return Path.join(components) } /// - See: Path.join(components: String...) - public static func join(components: [String]) -> String { + public static func join(_ components: [String]) -> String { return components.reduce("") { memo, component in let component = component.onesep if component.isEmpty { @@ -80,7 +80,7 @@ public struct Path { let abs = (path: string.isAbsolute, pivot: pivot.isAbsolute) - func go(path: [String], _ pivot: [String]) -> String { + func go(_ path: [String], _ pivot: [String]) -> String { let join = { [String].joined($0)(separator: "/") } if path.starts(with: pivot) { @@ -123,12 +123,12 @@ public struct Path { return go(clean(string), clean(pivot)) } - public func join(components: String...) -> String { + public func join(_ components: String...) -> String { return Path.join([string] + components) } } -private func clean(parts: [String.CharacterView]) -> [String] { +private func clean(_ parts: [String.CharacterView]) -> [String] { var out = [String]() for x in parts.map(String.init) { switch x { @@ -147,7 +147,7 @@ private func clean(parts: [String.CharacterView]) -> [String] { return out } -private func clean(string: String) -> [String] { +private func clean(_ string: String) -> [String] { return clean(string.characters.split(separator: "/")) } diff --git a/Sources/Utility/StringExtensions.swift b/Sources/Utility/StringExtensions.swift index bec72367bba..697178f55cc 100644 --- a/Sources/Utility/StringExtensions.swift +++ b/Sources/Utility/StringExtensions.swift @@ -14,8 +14,8 @@ extension String { all trailing \n (UNIX) or all trailing \r\n (Windows) (it will not remove mixed occurrences of both separators. */ - public func chomp(separator: String? = nil) -> String { - func scrub(separator: String) -> String { + public func chomp(_ separator: String? = nil) -> String { + func scrub(_ separator: String) -> String { var E = endIndex while self[startIndex.. startIndex { E = E.predecessor() @@ -73,7 +73,7 @@ extension String { /// Splits string around a delimiter string into up to two substrings /// If delimiter is not found, the second returned substring is nil - func splitAround(delimiter: String) -> (String, String?) { + func splitAround(_ delimiter: String) -> (String, String?) { let comps = self.characters.splitAround(Array(delimiter.characters)) let head = String(comps.0) if let tail = comps.1 { diff --git a/Sources/Utility/URL.swift b/Sources/Utility/URL.swift index c506c2e82be..1f5054f99b1 100644 --- a/Sources/Utility/URL.swift +++ b/Sources/Utility/URL.swift @@ -15,9 +15,9 @@ public struct URL { /// e.g. git@github.com:apple/swift returns "git" /// /// This is *not* a generic URI scheme parser! - public static func scheme(url: String) -> String? { + public static func scheme(_ url: String) -> String? { - func prefixOfSplitBy(delimiter: String) -> String? { + func prefixOfSplitBy(_ delimiter: String) -> String? { let (head, tail) = url.splitAround(delimiter) if tail == nil { //not found diff --git a/Sources/Utility/Verbosity.swift b/Sources/Utility/Verbosity.swift index dfbf1010bf5..e7a638355df 100644 --- a/Sources/Utility/Verbosity.swift +++ b/Sources/Utility/Verbosity.swift @@ -44,7 +44,7 @@ import func libc.fputs import var libc.stderr public class StandardErrorOutputStream: OutputStream { - public func write(string: String) { + public func write(_ string: String) { libc.fputs(string, libc.stderr) } } @@ -57,14 +57,14 @@ import func POSIX.system import func POSIX.popen import func POSIX.prettyArguments -public func system(args: String...) throws { +public func system(_ args: String...) throws { try Utility.system(args) } private let ESC = "\u{001B}" private let CSI = "\(ESC)[" -private func prettyArguments(arguments: [String]) -> String { +private func prettyArguments(_ arguments: [String]) -> String { guard arguments.count > 0 else { return "" } var arguments = arguments @@ -73,23 +73,23 @@ private func prettyArguments(arguments: [String]) -> String { return arg0 + " " + POSIX.prettyArguments(arguments) } -private func printArgumentsIfVerbose(arguments: [String]) { +private func printArgumentsIfVerbose(_ arguments: [String]) { if verbosity != .Concise { print(prettyArguments(arguments)) } } -public func system(arguments: [String], environment: [String:String] = [:]) throws { +public func system(_ arguments: [String], environment: [String:String] = [:]) throws { printArgumentsIfVerbose(arguments) try POSIX.system(arguments, environment: environment) } -public func popen(arguments: [String], redirectStandardError: Bool = false, environment: [String: String] = [:]) throws -> String { +public func popen(_ arguments: [String], redirectStandardError: Bool = false, environment: [String: String] = [:]) throws -> String { printArgumentsIfVerbose(arguments) return try POSIX.popen(arguments, redirectStandardError: redirectStandardError, environment: environment) } -public func popen(arguments: [String], redirectStandardError: Bool = false, environment: [String: String] = [:], body: String -> Void) throws { +public func popen(_ arguments: [String], redirectStandardError: Bool = false, environment: [String: String] = [:], body: String -> Void) throws { printArgumentsIfVerbose(arguments) return try POSIX.popen(arguments, redirectStandardError: redirectStandardError, environment: environment, body: body) } @@ -99,7 +99,7 @@ import func libc.fflush import var libc.stdout import enum POSIX.Error -public func system(arguments: String..., environment: [String:String] = [:], message: String?) throws { +public func system(_ arguments: String..., environment: [String:String] = [:], message: String?) throws { var out = "" do { if Utility.verbosity == .Concise { @@ -122,7 +122,7 @@ public func system(arguments: String..., environment: [String:String] = [:], mes } } -private func which(arg0: String) -> String { +private func which(_ arg0: String) -> String { if arg0.isAbsolute { return arg0 } else if let fullpath = try? POSIX.popen(["which", arg0]) { @@ -132,6 +132,6 @@ private func which(arg0: String) -> String { } } -private func blue(input: String) -> String { +private func blue(_ input: String) -> String { return CSI + "34m" + input + CSI + "0m" } diff --git a/Sources/Utility/misc.swift b/Sources/Utility/misc.swift index 912764a6d2b..6ec4e5f8d86 100644 --- a/Sources/Utility/misc.swift +++ b/Sources/Utility/misc.swift @@ -18,7 +18,7 @@ import var libc.ENOENT /** Recursively deletes the provided directory. */ -public func rmtree(components: String...) throws { +public func rmtree(_ components: String...) throws { let path = Path.join(components) var dirs = [String]() for entry in walk(path, recursively: true) { diff --git a/Sources/Utility/walk.swift b/Sources/Utility/walk.swift index 913567891fd..ff838895930 100644 --- a/Sources/Utility/walk.swift +++ b/Sources/Utility/walk.swift @@ -33,7 +33,7 @@ import var libc.DT_DIR - Note: setting recursively to `false` still causes the generator to feed you the directory; just not its contents. */ -public func walk(paths: String..., recursively: Bool = true) -> RecursibleDirectoryContentsGenerator { +public func walk(_ paths: String..., recursively: Bool = true) -> RecursibleDirectoryContentsGenerator { return RecursibleDirectoryContentsGenerator(path: Path.join(paths), recursionFilter: { _ in recursively }) } @@ -54,7 +54,7 @@ public func walk(paths: String..., recursively: Bool = true) -> RecursibleDirect - Note: returning `false` from `recursing` still produces that directory from the generator; just not its contents. */ -public func walk(paths: String..., recursing: (String) -> Bool) -> RecursibleDirectoryContentsGenerator { +public func walk(_ paths: String..., recursing: (String) -> Bool) -> RecursibleDirectoryContentsGenerator { return RecursibleDirectoryContentsGenerator(path: Path.join(paths), recursionFilter: recursing) } diff --git a/Sources/Xcodeproj/generate().swift b/Sources/Xcodeproj/generate().swift index 1592dd55119..e93ed75e70e 100644 --- a/Sources/Xcodeproj/generate().swift +++ b/Sources/Xcodeproj/generate().swift @@ -16,7 +16,7 @@ import POSIX Generates an xcodeproj at the specified path. - Returns: the path to the generated project */ -public func generate(dstdir dstdir: String, projectName: String, srcroot: String, modules: [XcodeModuleProtocol], externalModules: [XcodeModuleProtocol], products: [Product]) throws -> String { +public func generate(dstdir: String, projectName: String, srcroot: String, modules: [XcodeModuleProtocol], externalModules: [XcodeModuleProtocol], products: [Product]) throws -> String { let xcodeprojName = "\(projectName).xcodeproj" let xcodeprojPath = try mkdir(dstdir, xcodeprojName) @@ -55,7 +55,7 @@ public func generate(dstdir dstdir: String, projectName: String, srcroot: String } -private func open(path: String..., body: ((String) -> Void) -> Void) throws { +private func open(_ path: String..., body: ((String) -> Void) -> Void) throws { var error: ErrorProtocol? = nil try Utility.fopen(Path.join(path), mode: .Write) { fp in diff --git a/Sources/Xcodeproj/pbxproj().swift b/Sources/Xcodeproj/pbxproj().swift index dd9649ad211..46acc613b9d 100644 --- a/Sources/Xcodeproj/pbxproj().swift +++ b/Sources/Xcodeproj/pbxproj().swift @@ -15,7 +15,7 @@ import PackageType import Utility -public func pbxproj(srcroot srcroot: String, projectRoot: String, modules: [XcodeModuleProtocol], externalModules: [XcodeModuleProtocol], products _: [Product], printer print: (String) -> Void) { +public func pbxproj(srcroot: String, projectRoot: String, modules: [XcodeModuleProtocol], externalModules: [XcodeModuleProtocol], products _: [Product], printer print: (String) -> Void) { // let rootModulesSet = Set(modules).subtract(Set(externalModules)) let rootModulesSet = modules diff --git a/Sources/Xcodeproj/xcscheme().swift b/Sources/Xcodeproj/xcscheme().swift index 4783e3c0454..c6978e23950 100644 --- a/Sources/Xcodeproj/xcscheme().swift +++ b/Sources/Xcodeproj/xcscheme().swift @@ -10,7 +10,7 @@ import PackageType -func xcscheme(container container: String, modules: [XcodeModuleProtocol], printer print: (String) -> Void) { +func xcscheme(container: String, modules: [XcodeModuleProtocol], printer print: (String) -> Void) { print("") print("") print(" ") diff --git a/Sources/libc/String+Linux.swift b/Sources/libc/String+Linux.swift index b1cfe7efb37..a1a58549d7f 100644 --- a/Sources/libc/String+Linux.swift +++ b/Sources/libc/String+Linux.swift @@ -12,7 +12,7 @@ #if os(Linux) public extension String { - public func hasPrefix(str: String) -> Bool { + public func hasPrefix(_ str: String) -> Bool { if utf8.count < str.utf8.count { return false } @@ -24,7 +24,7 @@ return true } - public func hasSuffix(str: String) -> Bool { + public func hasSuffix(_ str: String) -> Bool { let count = utf8.count let strCount = str.utf8.count if count < strCount { diff --git a/Sources/swift-build/initPackage.swift b/Sources/swift-build/initPackage.swift index 1041dd5e215..d1dd9c55240 100644 --- a/Sources/swift-build/initPackage.swift +++ b/Sources/swift-build/initPackage.swift @@ -107,7 +107,7 @@ final class InitPackage { } } - private func writeLinuxMain(testsPath testsPath: String) throws { + private func writeLinuxMain(testsPath: String) throws { let linuxMain = Path.join(testsPath, "LinuxMain.swift") let linuxMainFP = try fopen(linuxMain, mode: .Write) defer { @@ -121,7 +121,7 @@ final class InitPackage { try fputs("])\n", linuxMainFP) } - private func writeTestFileStubs(testsPath testsPath: String) throws { + private func writeTestFileStubs(testsPath: String) throws { let testModule = Path.join(testsPath, pkgname) print("Creating Tests/\(pkgname)/") try mkdir(testModule) diff --git a/Sources/swift-build/main.swift b/Sources/swift-build/main.swift index d2cc3e85a24..c491b5ca556 100644 --- a/Sources/swift-build/main.swift +++ b/Sources/swift-build/main.swift @@ -47,13 +47,13 @@ do { try chdir(dir) } - func parseManifest(path path: String, baseURL: String) throws -> Manifest { + func parseManifest(path: String, baseURL: String) throws -> Manifest { let swiftc = Multitool.SWIFT_EXEC let libdir = Multitool.libdir return try Manifest(path: path, baseURL: baseURL, swiftc: swiftc, libdir: libdir) } - func fetch(root: String) throws -> (rootPackage: Package, externalPackages:[Package]) { + func fetch(_ root: String) throws -> (rootPackage: Package, externalPackages:[Package]) { let manifest = try parseManifest(path: root, baseURL: root) return try get(manifest, manifestParser: parseManifest) } diff --git a/Sources/swift-build/usage.swift b/Sources/swift-build/usage.swift index 20663ffdf90..eb55739b492 100644 --- a/Sources/swift-build/usage.swift +++ b/Sources/swift-build/usage.swift @@ -12,7 +12,7 @@ import protocol Build.Toolchain import enum Build.Configuration import Multitool -func usage(print: (String) -> Void = { print($0) }) { +func usage(_ print: (String) -> Void = { print($0) }) { //.........10.........20.........30.........40.........50.........60.........70.. print("OVERVIEW: Build sources into binary products") print("") diff --git a/Sources/swift-build/xp.swift b/Sources/swift-build/xp.swift index 2c693defb4b..a5cdaca63e8 100644 --- a/Sources/swift-build/xp.swift +++ b/Sources/swift-build/xp.swift @@ -15,7 +15,7 @@ import Build import POSIX #if os(Linux) -public func describe(prefix: String, _ conf: Configuration, _ modules: [Module], _ externalModules: Set, _ products: [Product], Xcc: [String], Xld: [String], Xswiftc: [String], toolchain: Toolchain) throws -> String { +public func describe(_ prefix: String, _ conf: Configuration, _ modules: [Module], _ externalModules: Set, _ products: [Product], Xcc: [String], Xld: [String], Xswiftc: [String], toolchain: Toolchain) throws -> String { do { return try Build.describe(prefix, conf, modules, externalModules, products, Xcc: Xcc, Xld: Xld, Xswiftc: Xswiftc, toolchain: toolchain) } catch { diff --git a/Sources/swift-test/test.swift b/Sources/swift-test/test.swift index f3fcdaf9d19..7902fde9b13 100644 --- a/Sources/swift-test/test.swift +++ b/Sources/swift-test/test.swift @@ -11,7 +11,7 @@ import PackageType import Utility -func test(path path: String, xctestArg: String? = nil) throws -> Bool { +func test(path: String, xctestArg: String? = nil) throws -> Bool { guard path.isValidTest else { throw Error.TestsExecutableNotFound diff --git a/Sources/swift-test/usage.swift b/Sources/swift-test/usage.swift index 483b2189bfa..1f68075c49a 100644 --- a/Sources/swift-test/usage.swift +++ b/Sources/swift-test/usage.swift @@ -10,7 +10,7 @@ See http://swift.org/CONTRIBUTORS.txt for Swift project authors import Multitool -func usage(print: (String) -> Void = { print($0) }) { +func usage(_ print: (String) -> Void = { print($0) }) { //.........10.........20.........30.........40.........50.........60.........70.. print("OVERVIEW: Build and run tests") print("") diff --git a/Tests/Functional/TestModuleMaps.swift b/Tests/Functional/TestModuleMaps.swift index bee49eec4c8..47d07ee3b40 100644 --- a/Tests/Functional/TestModuleMaps.swift +++ b/Tests/Functional/TestModuleMaps.swift @@ -21,7 +21,7 @@ private let dylib = "so" class ModuleMapsTestCase: XCTestCase { - private func fixture(name name: String, CModuleName: String, rootpkg: String, body: (String, [String]) throws -> Void) { + private func fixture(name: String, CModuleName: String, rootpkg: String, body: (String, [String]) throws -> Void) { FunctionalTestSuite.fixture(name: name) { prefix in let input = Path.join(prefix, CModuleName, "C/foo.c") let outdir = try mkdir(prefix, rootpkg, ".build/debug") @@ -54,7 +54,7 @@ class ModuleMapsTestCase: XCTestCase { XCTAssertBuilds(prefix, "packageA", Xld: Xld) - func verify(conf: String, file: StaticString = #file, line: UInt = #line) throws { + func verify(_ conf: String, file: StaticString = #file, line: UInt = #line) throws { let expectedOutput = "calling Y.bar()\nY.bar() called\nX.foo() called\n123\n" let out = try popen([Path.join(prefix, "packageA/.build", conf, "packageA")]) XCTAssertEqual(out, expectedOutput) diff --git a/Tests/Functional/TestValidLayouts.swift b/Tests/Functional/TestValidLayouts.swift index 4a870b62369..c997732c0a7 100644 --- a/Tests/Functional/TestValidLayouts.swift +++ b/Tests/Functional/TestValidLayouts.swift @@ -99,7 +99,7 @@ class ValidLayoutsTestCase: XCTestCase { //MARK: Utility extension ValidLayoutsTestCase { - func runLayoutFixture(name name: String, line: UInt = #line, @noescape body: (String) throws -> Void) { + func runLayoutFixture(name: String, line: UInt = #line, @noescape body: (String) throws -> Void) { let name = "ValidLayouts/\(name)" // 1. Rooted layout diff --git a/Tests/Functional/Utilities.swift b/Tests/Functional/Utilities.swift index 8f10e4d1c25..9f26b959429 100644 --- a/Tests/Functional/Utilities.swift +++ b/Tests/Functional/Utilities.swift @@ -23,7 +23,7 @@ import class Foundation.NSBundle func fixture(name fixtureName: String, tags: [String] = [], file: StaticString = #file, line: UInt = #line, @noescape body: (String) throws -> Void) { - func gsub(input: String) -> String { + func gsub(_ input: String) -> String { return input.characters.split(separator: "/").map(String.init).joined(separator: "_") } @@ -93,7 +93,7 @@ func swiftBuildPath() -> String { } -func executeSwiftBuild(chdir: String, configuration: Configuration = .Debug, printIfError: Bool = false, Xld: [String] = []) throws -> String { +func executeSwiftBuild(_ chdir: String, configuration: Configuration = .Debug, printIfError: Bool = false, Xld: [String] = []) throws -> String { var env = [String:String]() #if Xcode switch getenv("SWIFT_EXEC") { @@ -131,7 +131,7 @@ func executeSwiftBuild(chdir: String, configuration: Configuration = .Debug, pri } } -func mktmpdir(file: StaticString = #file, line: UInt = #line, @noescape body: (String) throws -> Void) { +func mktmpdir(_ file: StaticString = #file, line: UInt = #line, @noescape body: (String) throws -> Void) { do { try POSIX.mkdtemp("spm-tests") { dir in defer { _ = try? rmtree(dir) } @@ -142,7 +142,7 @@ func mktmpdir(file: StaticString = #file, line: UInt = #line, @noescape body: (S } } -func XCTAssertBuilds(paths: String..., configurations: Set = [.Debug, .Release], file: StaticString = #file, line: UInt = #line, Xld: [String] = []) { +func XCTAssertBuilds(_ paths: String..., configurations: Set = [.Debug, .Release], file: StaticString = #file, line: UInt = #line, Xld: [String] = []) { let prefix = Path.join(paths) for conf in configurations { @@ -155,7 +155,7 @@ func XCTAssertBuilds(paths: String..., configurations: Set = [.De } } -func XCTAssertBuildFails(paths: String..., file: StaticString = #file, line: UInt = #line) { +func XCTAssertBuildFails(_ paths: String..., file: StaticString = #file, line: UInt = #line) { let prefix = Path.join(paths) do { try executeSwiftBuild(prefix) @@ -169,27 +169,27 @@ func XCTAssertBuildFails(paths: String..., file: StaticString = #file, line: UIn } } -func XCTAssertFileExists(paths: String..., file: StaticString = #file, line: UInt = #line) { +func XCTAssertFileExists(_ paths: String..., file: StaticString = #file, line: UInt = #line) { let path = Path.join(paths) if !path.isFile { XCTFail("Expected file doesn’t exist: \(path)", file: file, line: line) } } -func XCTAssertDirectoryExists(paths: String..., file: StaticString = #file, line: UInt = #line) { +func XCTAssertDirectoryExists(_ paths: String..., file: StaticString = #file, line: UInt = #line) { let path = Path.join(paths) if !path.isDirectory { XCTFail("Expected directory doesn’t exist: \(path)", file: file, line: line) } } -func XCTAssertNoSuchPath(paths: String..., file: StaticString = #file, line: UInt = #line) { +func XCTAssertNoSuchPath(_ paths: String..., file: StaticString = #file, line: UInt = #line) { let path = Path.join(paths) if path.exists { XCTFail("path exists but should not: \(path)", file: file, line: line) } } -func system(args: String...) throws { +func system(_ args: String...) throws { try popen(args, redirectStandardError: true) } diff --git a/Tests/Get/DependencyGraphTests.swift b/Tests/Get/DependencyGraphTests.swift index e5bad547bd2..b846ed61289 100644 --- a/Tests/Get/DependencyGraphTests.swift +++ b/Tests/Get/DependencyGraphTests.swift @@ -16,7 +16,7 @@ class VersionGraphTests: XCTestCase { func testNoGraph() { class MockFetcher: _MockFetcher { - override func fetch(url url: String) throws -> Fetchable { + override func fetch(url: String) throws -> Fetchable { switch MockProject(rawValue: url)! { case .A: return MockCheckout(.A, [v1]) default: @@ -34,7 +34,7 @@ class VersionGraphTests: XCTestCase { func testOneDependency() { class MockFetcher: _MockFetcher { - override func fetch(url url: String) throws -> Fetchable { + override func fetch(url: String) throws -> Fetchable { switch MockProject(rawValue: url)! { case .A: return MockCheckout(.A, [v1], (MockProject.B.url, v1...v1)) case .B: return MockCheckout(.B, [v1]) @@ -54,7 +54,7 @@ class VersionGraphTests: XCTestCase { func testOneDepenencyWithMultipleAvailableVersions() { class MockFetcher: _MockFetcher { - override func fetch(url url: String) throws -> Fetchable { + override func fetch(url: String) throws -> Fetchable { switch MockProject(rawValue: url)! { case .A: return MockCheckout(.A, [v1], (MockProject.B.url, v1.. Fetchable { + override func fetch(url: String) throws -> Fetchable { switch MockProject(rawValue: url)! { case .A: return MockCheckout(.A, [v1], (MockProject.B.url, v1...v1)) case .B: return MockCheckout(.B, [v1], (MockProject.C.url, v1...v1)) @@ -96,7 +96,7 @@ class VersionGraphTests: XCTestCase { func testTwoDirectDependencies() { class MockFetcher: _MockFetcher { - override func fetch(url url: String) throws -> Fetchable { + override func fetch(url: String) throws -> Fetchable { switch MockProject(rawValue: url)! { case .A: return MockCheckout(.A, [v1], (MockProject.B.url, v1...v1), (MockProject.C.url, v1...v1)) case .B: return MockCheckout(.B, [v1]) @@ -118,7 +118,7 @@ class VersionGraphTests: XCTestCase { func testTwoDirectDependenciesWhereOneAlsoDependsOnTheOther() { class MockFetcher: _MockFetcher { - override func fetch(url url: String) throws -> Fetchable { + override func fetch(url: String) throws -> Fetchable { switch MockProject(rawValue: url)! { case .A: return MockCheckout(.A, [v1], (MockProject.B.url, v1...v1), (MockProject.C.url, v1...v1)) case .B: return MockCheckout(.B, [v1], (MockProject.C.url, v1...v1)) @@ -141,7 +141,7 @@ class VersionGraphTests: XCTestCase { func testSimpleVersionRestrictedGraph() { class MockFetcher: _MockFetcher { - override func fetch(url url: String) throws -> Fetchable { + override func fetch(url: String) throws -> Fetchable { switch MockProject(rawValue: url)! { case .A: return MockCheckout(.A, [v1], (MockProject.C.url, v123.. Fetchable { + override func fetch(url: String) throws -> Fetchable { switch MockProject(rawValue: url)! { case .A: return MockCheckout(.A, [v1], (MockProject.C.url, Version(1,2,3).. Fetchable { + override func fetch(url: String) throws -> Fetchable { switch MockProject(rawValue: url)! { case .A: return MockCheckout(.A, [v1], (MockProject.C.url, Version(1,2,3).. Fetchable { + override func fetch(url: String) throws -> Fetchable { switch MockProject(rawValue: url)! { case .A: return MockCheckout(.A, [v1], (MockProject.C.url, Version(1,2,3).. Fetchable { + override func fetch(url: String) throws -> Fetchable { return MockCheckout(.A, [v2]) } } @@ -288,7 +288,7 @@ class VersionGraphTests: XCTestCase { // // func testGetRequiresUpdateToAlreadyInstalledPackage() { // class MyMockFetcher: MockFetcher { -// override func specsForCheckout(checkout: MockCheckout) -> [(String, Range)] { +// override func specsForCheckout(_ checkout: MockCheckout) -> [(String, Range)] { // switch checkout.project { // case .A: return [(MockProject.C.url, Version(1,2,3).. Bool { private class _MockFetcher: Fetcher { private typealias T = MockCheckout - func find(url url: String) throws -> Fetchable? { + func find(url: String) throws -> Fetchable? { return nil } - func finalize(fetchable: Fetchable) throws -> MockCheckout { + func finalize(_ fetchable: Fetchable) throws -> MockCheckout { return fetchable as! T } - func fetch(url url: String) throws -> Fetchable { + func fetch(url: String) throws -> Fetchable { fatalError("This must be implemented in each test") } } diff --git a/Tests/Get/RawCloneTests.swift b/Tests/Get/RawCloneTests.swift index b31bdaa034b..d93f606b669 100644 --- a/Tests/Get/RawCloneTests.swift +++ b/Tests/Get/RawCloneTests.swift @@ -43,7 +43,7 @@ class GitTests: XCTestCase { //MARK: - Helpers -func makeGitRepo(dstdir: String, tag: String? = nil, file: StaticString = #file, line: UInt = #line) -> Git.Repo? { +func makeGitRepo(_ dstdir: String, tag: String? = nil, file: StaticString = #file, line: UInt = #line) -> Git.Repo? { do { let file = Path.join(dstdir, "file.swift") try popen(["touch", file]) @@ -64,7 +64,7 @@ func makeGitRepo(dstdir: String, tag: String? = nil, file: StaticString = #file, return nil } -private func tryCloningRepoWithTag(tag: String?, shouldCrash: Bool) { +private func tryCloningRepoWithTag(_ tag: String?, shouldCrash: Bool) { var done = !shouldCrash mktmpdir { path in makeGitRepo(path, tag: tag)! diff --git a/Tests/ManifestParser/ManifestTests.swift b/Tests/ManifestParser/ManifestTests.swift index 337ea588716..a05803a8320 100644 --- a/Tests/ManifestParser/ManifestTests.swift +++ b/Tests/ManifestParser/ManifestTests.swift @@ -38,7 +38,7 @@ class ManifestTests: XCTestCase { let swiftc = Path.join(Process.arguments.first!, "../swiftc").abspath() #endif - private func loadManifest(inputName: String, line: UInt = #line, body: (Manifest) -> Void) { + private func loadManifest(_ inputName: String, line: UInt = #line, body: (Manifest) -> Void) { do { let input = Path.join(#file, "../Inputs", inputName).normpath body(try Manifest(path: input, baseURL: input.parentDirectory, swiftc: swiftc, libdir: libdir)) diff --git a/Tests/ManifestParser/SerializationTests.swift b/Tests/ManifestParser/SerializationTests.swift index fd960f7463d..705c8f4ef9c 100644 --- a/Tests/ManifestParser/SerializationTests.swift +++ b/Tests/ManifestParser/SerializationTests.swift @@ -13,7 +13,7 @@ import PackageDescription import Utility import XCTest -private func parseTOML(data: String) -> TOMLItem { +private func parseTOML(_ data: String) -> TOMLItem { do { return try TOMLItem.parse(data) } catch let err { diff --git a/Tests/ManifestParser/TOMLTests.swift b/Tests/ManifestParser/TOMLTests.swift index c97f040fc83..5d4252ed986 100644 --- a/Tests/ManifestParser/TOMLTests.swift +++ b/Tests/ManifestParser/TOMLTests.swift @@ -12,15 +12,15 @@ import XCTest // Test the basic types. -private func toArray(items: [TOMLItem]) -> TOMLItem { +private func toArray(_ items: [TOMLItem]) -> TOMLItem { return .Array(contents: TOMLItemArray(items: items)) } -private func toTable(items: [String: TOMLItem]) -> TOMLItem { +private func toTable(_ items: [String: TOMLItem]) -> TOMLItem { return .Table(contents: TOMLItemTable(items: items)) } -private func parseTOML(data: String) -> TOMLItem { +private func parseTOML(_ data: String) -> TOMLItem { do { return try TOMLItem.parse(data) } catch let err { diff --git a/Tests/PackageDescription/VersionTests.swift b/Tests/PackageDescription/VersionTests.swift index 045af6d3c44..50263d21c77 100644 --- a/Tests/PackageDescription/VersionTests.swift +++ b/Tests/PackageDescription/VersionTests.swift @@ -15,7 +15,7 @@ import XCTest class VersionTests: XCTestCase { func testEquality() { - func test(@autoclosure v: () -> Version) { + func test(@autoclosure _ v: () -> Version) { XCTAssertEqual(v(), v()) } diff --git a/Tests/Transmute/ModuleTests.swift b/Tests/Transmute/ModuleTests.swift index 73c24637a65..83319beba51 100644 --- a/Tests/Transmute/ModuleTests.swift +++ b/Tests/Transmute/ModuleTests.swift @@ -21,7 +21,7 @@ extension Module { self.init(name: name) } - private func dependsOn(target: Module) { + private func dependsOn(_ target: Module) { dependencies.append(target) } diff --git a/Tests/Utility/CollectionTests.swift b/Tests/Utility/CollectionTests.swift index 35a1ec83d8b..cd25de8909f 100644 --- a/Tests/Utility/CollectionTests.swift +++ b/Tests/Utility/CollectionTests.swift @@ -38,7 +38,7 @@ class CollectionTests: XCTestCase { func testPartitionByClosure() { - func eq(lhs: ([Int], [Int]), _ rhs: ([Int], [Int]), file: StaticString = #file, line: UInt = #line) { + func eq(_ lhs: ([Int], [Int]), _ rhs: ([Int], [Int]), file: StaticString = #file, line: UInt = #line) { XCTAssertEqual(lhs.0, rhs.0, file: file, line: line) XCTAssertEqual(lhs.1, rhs.1, file: file, line: line) } @@ -53,7 +53,7 @@ class CollectionTests: XCTestCase { func testSplitAround() { - func eq(lhs: ([Character], [Character]?), _ rhs: ([Character], [Character]?), file: StaticString = #file, line: UInt = #line) { + func eq(_ lhs: ([Character], [Character]?), _ rhs: ([Character], [Character]?), file: StaticString = #file, line: UInt = #line) { XCTAssertEqual(lhs.0, rhs.0, file: file, line: line) XCTAssertEqual(lhs.1 ?? [], rhs.1 ?? [], file: file, line: line) } diff --git a/Tests/Utility/FileTests.swift b/Tests/Utility/FileTests.swift index 9472af01af2..128dbfda08a 100644 --- a/Tests/Utility/FileTests.swift +++ b/Tests/Utility/FileTests.swift @@ -13,7 +13,7 @@ import XCTest class FileTests: XCTestCase { - private func loadInputFile(name: String) -> File { + private func loadInputFile(_ name: String) -> File { let input = Path.join(#file, "../Inputs", name).normpath return File(path: input) } diff --git a/Tests/Utility/StringTests.swift b/Tests/Utility/StringTests.swift index a4e2e8f98bd..84179828fc8 100644 --- a/Tests/Utility/StringTests.swift +++ b/Tests/Utility/StringTests.swift @@ -45,7 +45,7 @@ class StringTests: XCTestCase { func testSplitAround() { - func eq(lhs: (String, String?), _ rhs: (String, String?), file: StaticString = #file, line: UInt = #line) { + func eq(_ lhs: (String, String?), _ rhs: (String, String?), file: StaticString = #file, line: UInt = #line) { XCTAssertEqual(lhs.0, rhs.0, file: file, line: line) XCTAssertEqual(lhs.1, rhs.1, file: file, line: line) } diff --git a/Tests/Xcodeproj/TestGeneration.swift b/Tests/Xcodeproj/TestGeneration.swift index 1c04e0c8b4d..5401686138c 100644 --- a/Tests/Xcodeproj/TestGeneration.swift +++ b/Tests/Xcodeproj/TestGeneration.swift @@ -16,7 +16,7 @@ import XCTest // copy pasta -func mktmpdir(file: StaticString = #file, line: UInt = #line, @noescape body: (String) throws -> Void) { +func mktmpdir(_ file: StaticString = #file, line: UInt = #line, @noescape body: (String) throws -> Void) { do { try POSIX.mkdtemp("spm-tests") { dir in defer { _ = try? rmtree(dir) } @@ -27,7 +27,7 @@ func mktmpdir(file: StaticString = #file, line: UInt = #line, @noescape body: (S } } -func XCTAssertDirectoryExists(paths: String..., file: StaticString = #file, line: UInt = #line) { +func XCTAssertDirectoryExists(_ paths: String..., file: StaticString = #file, line: UInt = #line) { let path = Path.join(paths) if !path.isDirectory { XCTFail("Expected directory doesn’t exist: \(path)", file: file, line: line)