Skip to content

Commit 66c9fb2

Browse files
committed
Merge pull request #171 from apple/swift-3-api-guidelines
Port SwiftPM to the new Swift 3 API
2 parents 5040f9e + 02f42e3 commit 66c9fb2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+135
-126
lines changed

Fixtures/DependencyResolution/External/Complex/FisherYates/src/Fisher-Yates_Shuffle.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ import Darwin
44
import Glibc
55
#endif
66

7-
public extension CollectionType {
8-
func shuffle() -> [Generator.Element] {
7+
public extension Collection {
8+
func shuffle() -> [Iterator.Element] {
99
var array = Array(self)
1010
array.shuffleInPlace()
1111

1212
return array
1313
}
1414
}
1515

16-
public extension MutableCollectionType where Index == Int {
16+
public extension MutableCollection where Index == Int {
1717
mutating func shuffleInPlace() {
1818
guard count > 1 else { return }
1919

Fixtures/DependencyResolution/External/IgnoreIndirectTests/FisherYates/src/Fisher-Yates_Shuffle.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ import Darwin
44
import Glibc
55
#endif
66

7-
public extension CollectionType {
8-
func shuffle() -> [Generator.Element] {
7+
public extension Collection {
8+
func shuffle() -> [Iterator.Element] {
99
var array = Array(self)
1010
array.shuffleInPlace()
1111

1212
return array
1313
}
1414
}
1515

16-
public extension MutableCollectionType where Index == Int {
16+
public extension MutableCollection where Index == Int {
1717
mutating func shuffleInPlace() {
1818
guard count > 1 else { return }
1919

Sources/Build/Error.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
See http://swift.org/CONTRIBUTORS.txt for Swift project authors
99
*/
1010

11-
public enum Error: ErrorType {
11+
public enum Error: ErrorProtocol {
1212
case NoModules
1313
case InvalidPlatformPath
1414
}

Sources/Build/YAML.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@ extension Array where Element: YAMLRepresentable {
3737
return input
3838
}
3939
let stringArray = self.flatMap { String($0) }
40-
return "[" + stringArray.map(quote).joinWithSeparator(", ") + "]"
40+
return "[" + stringArray.map(quote).joined(separator: ", ") + "]"
4141
}
4242
}

Sources/Get/Error.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
import struct PackageDescription.Version
1212

13-
public enum Error: ErrorType {
13+
public enum Error: ErrorProtocol {
1414

1515
public typealias ClonePath = String
1616
public typealias URL = String

Sources/Get/Git.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ extension Git {
4646
extension Git.Repo {
4747
var versions: [Version] {
4848
let out = (try? popen([Git.tool, "-C", path, "tag", "-l"])) ?? ""
49-
let tags = out.characters.split(Character.newline)
50-
let versions = tags.flatMap(Version.init).sort()
49+
let tags = out.characters.split(separator: Character.newline)
50+
let versions = tags.flatMap(Version.init).sorted()
5151
if !versions.isEmpty {
5252
return versions
5353
} else {
54-
return tags.flatMap(Version.vprefix).sort()
54+
return tags.flatMap(Version.vprefix).sorted()
5555
}
5656
}
5757

Sources/Get/Range.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@
88
See http://swift.org/CONTRIBUTORS.txt for Swift project authors
99
*/
1010

11-
extension Range where Element: BidirectionalIndexType, Element: Comparable {
11+
extension Range where Element: BidirectionalIndex, Element: Comparable {
1212

1313
/**
1414
- Returns: A new Range with startIndex and endIndex constrained such that
1515
the returned range is entirely within this Range and the provided Range.
1616
If the two ranges do not overlap at all returns `nil`.
1717
*/
1818
func constrain(to constraint: Range) -> Range? {
19-
let start = max(self.startIndex, constraint.startIndex)
20-
let end = min(self.endIndex, constraint.endIndex)
19+
let start = Swift.max(self.startIndex, constraint.startIndex)
20+
let end = Swift.min(self.endIndex, constraint.endIndex)
2121
if start < end {
2222
return start..<end
2323
} else {

Sources/ManifestParser/TOML.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ private struct Lexer {
277277
break
278278
}
279279
}
280-
return .StringLiteral(value: String(utf8[Range(start: startIndex.successor(), end: endIndex)]))
280+
return .StringLiteral(value: String(utf8[startIndex.successor()..<endIndex]))
281281

282282
// Numeric literals.
283283
//
@@ -288,7 +288,7 @@ private struct Lexer {
288288
while let c = look() where c.isNumberChar() {
289289
eat()
290290
}
291-
return .Number(value: String(utf8[Range(start: startIndex, end: index)]))
291+
return .Number(value: String(utf8[startIndex..<index]))
292292

293293
// Identifiers.
294294
case let c where c.isIdentifierChar():
@@ -298,7 +298,7 @@ private struct Lexer {
298298
}
299299

300300
// Match special strings.
301-
let value: String = String(utf8[Range(start: startIndex, end: index)])
301+
let value: String = String(utf8[startIndex..<index])
302302
switch value {
303303
case "true":
304304
return .Boolean(value: true)
@@ -364,7 +364,7 @@ extension Lexer.Token : CustomStringConvertible {
364364
}
365365
}
366366

367-
private struct LexerTokenGenerator : GeneratorType {
367+
private struct LexerTokenGenerator : IteratorProtocol {
368368
var lexer: Lexer
369369

370370
mutating func next() -> Lexer.Token? {
@@ -376,8 +376,8 @@ private struct LexerTokenGenerator : GeneratorType {
376376
}
377377
}
378378

379-
extension Lexer : LazySequenceType {
380-
func generate() -> LexerTokenGenerator {
379+
extension Lexer : LazySequenceProtocol {
380+
func makeIterator() -> LexerTokenGenerator {
381381
return LexerTokenGenerator(lexer: self)
382382
}
383383
}
@@ -470,7 +470,7 @@ private struct Parser {
470470
private mutating func findInsertPoint(topLevelTable: TOMLItemTable, _ specifiers: [String], isAppend: Bool, startToken: Lexer.Token) -> TOMLItemTable {
471471
// FIXME: Handle TOML requirements (sole definition).
472472
var into = topLevelTable
473-
for (i,specifier) in specifiers.enumerate() {
473+
for (i,specifier) in specifiers.enumerated() {
474474
// If this is an append, then the last key is handled as a special case.
475475
if isAppend && i == specifiers.count - 1 {
476476
if let existing = into.items[specifier] {
@@ -742,7 +742,7 @@ private struct Parser {
742742
}
743743

744744
/// Generic error thrown for any TOML error.
745-
public struct TOMLParsingError : ErrorType {
745+
public struct TOMLParsingError : ErrorProtocol {
746746
/// The raw errors.
747747
public let errors: [String]
748748
}

Sources/Multitool/Error.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ import var Utility.stderr
1313
import PackageType
1414
import libc
1515

16-
public enum CommandLineError: ErrorType {
16+
public enum CommandLineError: ErrorProtocol {
1717
public enum UsageMode {
1818
case Print, ImplySwiftBuild, ImplySwiftTest
1919
}
2020
case InvalidUsage(String, UsageMode)
2121
}
2222

23-
public enum Error: ErrorType {
23+
public enum Error: ErrorProtocol {
2424
case NoManifestFound
2525
}
2626

@@ -41,12 +41,12 @@ extension Error: CustomStringConvertible {
4141
if isatty(fileno(libc.stdin)) {
4242
switch mode {
4343
case .ImplySwiftBuild:
44-
print("enter `swift build --help' for usage information", toStream: &stderr)
44+
print("enter `swift build --help' for usage information", to: &stderr)
4545
case .ImplySwiftTest:
46-
print("enter `swift test --help' for usage information", toStream: &stderr)
46+
print("enter `swift test --help' for usage information", to: &stderr)
4747
case .Print:
48-
print("", toStream: &stderr)
49-
usage { print($0, toStream: &stderr) }
48+
print("", to: &stderr)
49+
usage { print($0, to: &stderr) }
5050
}
5151
}
5252
default:
@@ -65,8 +65,8 @@ private func red(input: Any) -> String {
6565

6666
private func perror(msg: Any) {
6767
if !isatty(fileno(libc.stderr)) {
68-
print("swift-build: error:", msg, toStream: &stderr)
68+
print("swift-build: error:", msg, to: &stderr)
6969
} else {
70-
print(red("error:"), msg, toStream: &stderr)
70+
print(red("error:"), msg, to: &stderr)
7171
}
7272
}

Sources/POSIX/Error.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
See http://swift.org/CONTRIBUTORS.txt for Swift project authors
99
*/
1010

11-
public enum SystemError: ErrorType {
11+
public enum SystemError: ErrorProtocol {
1212
case chdir(Int32)
1313
case close(Int32)
1414
case dirfd(Int32, String)
@@ -43,7 +43,7 @@ extension SystemError: CustomStringConvertible {
4343

4444
func strerror(errno: Int32) -> String {
4545
let cmsg = libc.strerror(errno)
46-
let msg = String.fromCString(cmsg) ?? "Unknown Error"
46+
let msg = String(validatingUTF8: cmsg) ?? "Unknown Error"
4747
return "\(msg) (\(errno))"
4848
}
4949

@@ -101,12 +101,12 @@ extension SystemError: CustomStringConvertible {
101101
}
102102

103103

104-
public enum Error: ErrorType {
104+
public enum Error: ErrorProtocol {
105105
case ExitStatus(Int32, [String])
106106
case ExitSignal
107107
}
108108

109-
public enum ShellError: ErrorType {
109+
public enum ShellError: ErrorProtocol {
110110
case system(arguments: [String], SystemError)
111111
case popen(arguments: [String], SystemError)
112112
}

0 commit comments

Comments
 (0)