Skip to content

Commit 7c17aae

Browse files
committed
Sync with SwiftPM trunk
1 parent 8aad804 commit 7c17aae

15 files changed

+166
-30
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
/Packages
44
/*.xcodeproj
55
xcuserdata/
6+
.swiftpm

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:4.2
1+
// swift-tools-version:5.1
22

33
/*
44
This source file is part of the Swift.org open source project

Sources/TSCBasic/DictionaryLiteralExtensions.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// Can't conform a protocol explicitly with certain where clause for now but it'd be resolved by SE-0143.
1212
// ref: https://github.com/apple/swift-evolution/blob/master/proposals/0143-conditional-conformances.md
1313
// MARK: CustomStringConvertible
14-
extension DictionaryLiteral where Key: CustomStringConvertible, Value: CustomStringConvertible {
14+
extension KeyValuePairs where Key: CustomStringConvertible, Value: CustomStringConvertible {
1515
/// A string that represents the contents of the dictionary literal.
1616
public var description: String {
1717
let lastCount = self.count - 1
@@ -25,8 +25,8 @@ extension DictionaryLiteral where Key: CustomStringConvertible, Value: CustomStr
2525
}
2626

2727
// MARK: Equatable
28-
extension DictionaryLiteral where Key: Equatable, Value: Equatable {
29-
public static func ==(lhs: DictionaryLiteral<Key,Value>, rhs: DictionaryLiteral<Key,Value>) -> Bool {
28+
extension KeyValuePairs where Key: Equatable, Value: Equatable {
29+
public static func ==(lhs: KeyValuePairs<Key,Value>, rhs: KeyValuePairs<Key,Value>) -> Bool {
3030
if lhs.count != rhs.count {
3131
return false
3232
}

Sources/TSCBasic/FileSystem.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@ public class InMemoryFileSystem: FileSystem {
665665
// Ignore root and get the parent node's content if its a directory.
666666
guard !path.isRoot,
667667
let parent = try? getNode(path.parentDirectory),
668-
case .directory(let contents)? = parent?.contents else {
668+
case .directory(let contents) = parent.contents else {
669669
return
670670
}
671671
// Set it to nil to release the contents.

Sources/TSCBasic/GraphAlgorithms.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public func findCycle<T: Hashable>(
121121
func visit(_ node: T, _ successors: (T) throws -> [T]) rethrows -> (path: [T], cycle: [T])? {
122122
// If this node is already in the current path then we have found a cycle.
123123
if !path.append(node) {
124-
let index = path.index(of: node)!
124+
let index = path.firstIndex(of: node)!
125125
return (Array(path[path.startIndex..<index]), Array(path[index..<path.endIndex]))
126126
}
127127

Sources/TSCBasic/JSON.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public enum JSON {
4545
case dictionary([String: JSON])
4646

4747
/// An ordered dictionary.
48-
case orderedDictionary(DictionaryLiteral<String, JSON>)
48+
case orderedDictionary(KeyValuePairs<String, JSON>)
4949
}
5050

5151
/// A JSON representation of an element.
@@ -262,7 +262,7 @@ extension JSON {
262262

263263
/// Load a JSON item from a byte string.
264264
public init(bytes: ByteString) throws {
265-
try self.init(data: Data(bytes: bytes.contents))
265+
try self.init(data: Data(bytes.contents))
266266
}
267267

268268
/// Convenience initalizer for UTF8 encoded strings.

Sources/TSCBasic/JSONMapper.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ extension JSON {
4141

4242
/// Returns an optional JSON mappable object from a given key.
4343
public func get<T: JSONMappable>(_ key: String) -> T? {
44-
return try? get(key)
44+
if let object: JSON = try? get(key) {
45+
return try? T.init(json: object)
46+
}
47+
return nil
4548
}
4649

4750
/// Returns a JSON mappable array from a given key.

Sources/TSCBasic/OrderedDictionary.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public struct OrderedDictionary<Key: Hashable, Value> {
7575
return nil
7676
}
7777
dict[key] = nil
78-
array.remove(at: array.index(of: key)!)
78+
array.remove(at: array.firstIndex(of: key)!)
7979
return value
8080
}
8181

Sources/TSCBasic/OrderedSet.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public struct OrderedSet<E: Hashable>: Equatable, Collection {
9898
let _removedElement = set.remove(element)
9999
guard let removedElement = _removedElement else { return nil }
100100

101-
let idx = array.index(of: element)!
101+
let idx = array.firstIndex(of: element)!
102102
array.remove(at: idx)
103103

104104
return removedElement

Sources/TSCBasic/StringConversions.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ extension String {
4545
public func spm_shellEscaped() -> String {
4646

4747
// If all the characters in the string are in whitelist then no need to escape.
48-
guard let pos = utf8.index(where: { !inShellWhitelist($0) }) else {
48+
guard let pos = utf8.firstIndex(where: { !inShellWhitelist($0) }) else {
4949
return self
5050
}
5151

5252
// If there are no single quotes then we can just wrap the string around single quotes.
53-
guard let singleQuotePos = utf8[pos...].index(of: UInt8(ascii: "'")) else {
53+
guard let singleQuotePos = utf8[pos...].firstIndex(of: UInt8(ascii: "'")) else {
5454
return "'" + self + "'"
5555
}
5656

0 commit comments

Comments
 (0)