Skip to content

Commit ac4a4b3

Browse files
author
Mohit Athwani
committed
Merge remote-tracking branch 'upstream/master'
2 parents 7ea3aad + f1ddd0c commit ac4a4b3

File tree

4 files changed

+23
-12
lines changed

4 files changed

+23
-12
lines changed

Foundation/NSError.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -377,8 +377,8 @@ extension __BridgedNSError where Self: RawRepresentable, Self.RawValue: SignedIn
377377
}
378378

379379
public extension __BridgedNSError where Self: RawRepresentable, Self.RawValue: SignedInteger {
380-
public final var _domain: String { return Self._nsErrorDomain }
381-
public final var _code: Int { return Int(rawValue.toIntMax()) }
380+
public var _domain: String { return Self._nsErrorDomain }
381+
public var _code: Int { return Int(rawValue.toIntMax()) }
382382

383383
public init?(rawValue: RawValue) {
384384
self = unsafeBitCast(rawValue, to: Self.self)
@@ -392,7 +392,7 @@ public extension __BridgedNSError where Self: RawRepresentable, Self.RawValue: S
392392
self.init(rawValue: RawValue(IntMax(_bridgedNSError.code)))
393393
}
394394

395-
public final var hashValue: Int { return _code }
395+
public var hashValue: Int { return _code }
396396
}
397397

398398
// Allow two bridged NSError types to be compared.
@@ -403,8 +403,8 @@ extension __BridgedNSError where Self: RawRepresentable, Self.RawValue: Unsigned
403403
}
404404

405405
public extension __BridgedNSError where Self: RawRepresentable, Self.RawValue: UnsignedInteger {
406-
public final var _domain: String { return Self._nsErrorDomain }
407-
public final var _code: Int {
406+
public var _domain: String { return Self._nsErrorDomain }
407+
public var _code: Int {
408408
return Int(bitPattern: UInt(rawValue.toUIntMax()))
409409
}
410410

@@ -420,7 +420,7 @@ public extension __BridgedNSError where Self: RawRepresentable, Self.RawValue: U
420420
self.init(rawValue: RawValue(UIntMax(UInt(_bridgedNSError.code))))
421421
}
422422

423-
public final var hashValue: Int { return _code }
423+
public var hashValue: Int { return _code }
424424
}
425425

426426
/// Describes a raw representable type that is bridged to a particular

Foundation/NSOrderedSet.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ extension NSOrderedSet {
148148
open func objects(at indexes: IndexSet) -> [Any] {
149149
var entries = [Any]()
150150
for idx in indexes {
151-
if idx >= count && idx < 0 {
151+
guard idx < count && idx >= 0 else {
152152
fatalError("\(self): Index out of bounds")
153153
}
154154
entries.append(object(at: idx))
@@ -338,12 +338,12 @@ extension NSOrderedSet {
338338
open class NSMutableOrderedSet : NSOrderedSet {
339339

340340
open func insert(_ object: Any, at idx: Int) {
341-
guard idx < count && idx >= 0 else {
341+
guard idx <= count && idx >= 0 else {
342342
fatalError("\(self): Index out of bounds")
343343
}
344344

345345
let value = _SwiftValue.store(object)
346-
346+
347347
if contains(value) {
348348
return
349349
}

Foundation/Progress.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,8 @@ open class Progress : NSObject {
292292
open var pausingHandler: (() -> Void)? {
293293
didSet {
294294
guard let handler = pausingHandler else { return }
295-
// If we're already cancelled, then invoke it - asynchronously
296-
if isCancelled {
295+
// If we're already paused, then invoke it - asynchronously
296+
if isPaused {
297297
DispatchQueue.global().async {
298298
handler()
299299
}

TestFoundation/TestNSOrderedSet.swift

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ class TestNSOrderedSet : XCTestCase {
4343
("test_ReplaceObject", test_ReplaceObject),
4444
("test_ExchangeObjects", test_ExchangeObjects),
4545
("test_MoveObjects", test_MoveObjects),
46-
("test_InserObjects", test_InsertObjects),
46+
("test_InsertObjects", test_InsertObjects),
47+
("test_Insert", test_Insert),
4748
("test_SetObjectAtIndex", test_SetObjectAtIndex),
4849
("test_RemoveObjectsInRange", test_RemoveObjectsInRange),
4950
("test_ReplaceObjectsAtIndexes", test_ReplaceObjectsAtIndexes),
@@ -252,6 +253,16 @@ class TestNSOrderedSet : XCTestCase {
252253
XCTAssertEqual(set[4] as? String, "baz")
253254
}
254255

256+
func test_Insert() {
257+
let set = NSMutableOrderedSet()
258+
set.insert("foo", at: 0)
259+
XCTAssertEqual(set.count, 1)
260+
XCTAssertEqual(set[0] as? String, "foo")
261+
set.insert("bar", at: 1)
262+
XCTAssertEqual(set.count, 2)
263+
XCTAssertEqual(set[1] as? String, "bar")
264+
}
265+
255266
func test_SetObjectAtIndex() {
256267
let set = NSMutableOrderedSet(arrayLiteral: "foo", "bar", "baz")
257268
set.setObject("123", at: 1)

0 commit comments

Comments
 (0)