Skip to content

Commit 7ef06af

Browse files
authored
Merge pull request #494 from CodaFi/some-type-of-wei
Update for SE-0096
2 parents e367429 + 04b9b81 commit 7ef06af

25 files changed

+148
-148
lines changed

Foundation/Measurement.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ extension Measurement where UnitType : Dimension {
5454
return Measurement(value: value, unit: otherUnit)
5555
} else {
5656
let valueInTermsOfBase = unit.converter.baseUnitValue(fromValue: value)
57-
if otherUnit.isEqual(unit.dynamicType.baseUnit()) {
57+
if otherUnit.isEqual(type(of: unit).baseUnit()) {
5858
return Measurement(value: valueInTermsOfBase, unit: otherUnit)
5959
} else {
6060
let otherValueFromTermsOfBase = otherUnit.converter.value(fromBaseUnitValue: valueInTermsOfBase)
@@ -93,7 +93,7 @@ public func +<UnitType : Dimension>(lhs: Measurement<UnitType>, rhs: Measurement
9393
} else {
9494
let lhsValueInTermsOfBase = lhs.unit.converter.baseUnitValue(fromValue: lhs.value)
9595
let rhsValueInTermsOfBase = rhs.unit.converter.baseUnitValue(fromValue: rhs.value)
96-
return Measurement(value: lhsValueInTermsOfBase + rhsValueInTermsOfBase, unit: lhs.unit.dynamicType.baseUnit())
96+
return Measurement(value: lhsValueInTermsOfBase + rhsValueInTermsOfBase, unit: type(of: lhs.unit).baseUnit())
9797
}
9898
}
9999

@@ -118,7 +118,7 @@ public func -<UnitType : Dimension>(lhs: Measurement<UnitType>, rhs: Measurement
118118
} else {
119119
let lhsValueInTermsOfBase = lhs.unit.converter.baseUnitValue(fromValue: lhs.value)
120120
let rhsValueInTermsOfBase = rhs.unit.converter.baseUnitValue(fromValue: rhs.value)
121-
return Measurement(value: lhsValueInTermsOfBase - rhsValueInTermsOfBase, unit: lhs.unit.dynamicType.baseUnit())
121+
return Measurement(value: lhsValueInTermsOfBase - rhsValueInTermsOfBase, unit: type(of: lhs.unit).baseUnit())
122122
}
123123
}
124124

Foundation/NSArray.swift

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ public class NSArray : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NS
3939
internal var _storage = [AnyObject]()
4040

4141
public var count: Int {
42-
guard self.dynamicType === NSArray.self || self.dynamicType === NSMutableArray.self else {
42+
guard type(of: self) === NSArray.self || type(of: self) === NSMutableArray.self else {
4343
NSRequiresConcreteImplementation()
4444
}
4545
return _storage.count
4646
}
4747

4848
public func object(at index: Int) -> AnyObject {
49-
guard self.dynamicType === NSArray.self || self.dynamicType === NSMutableArray.self else {
49+
guard type(of: self) === NSArray.self || type(of: self) === NSMutableArray.self else {
5050
NSRequiresConcreteImplementation()
5151
}
5252
return _storage[index]
@@ -79,7 +79,7 @@ public class NSArray : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NS
7979
self.init(objects: UnsafePointer<AnyObject?>(objects), count: Int(cnt))
8080
objects.deinitialize(count: Int(cnt))
8181
objects.deallocate(capacity: Int(cnt))
82-
} else if aDecoder.dynamicType == NSKeyedUnarchiver.self || aDecoder.containsValue(forKey: "NS.objects") {
82+
} else if type(of: aDecoder) == NSKeyedUnarchiver.self || aDecoder.containsValue(forKey: "NS.objects") {
8383
let objects = aDecoder._decodeArrayOfObjectsForKey("NS.objects")
8484
self.init(array: objects)
8585
} else {
@@ -114,10 +114,10 @@ public class NSArray : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NS
114114
}
115115

116116
public func copy(with zone: NSZone? = nil) -> AnyObject {
117-
if self.dynamicType === NSArray.self {
117+
if type(of: self) === NSArray.self {
118118
// return self for immutable type
119119
return self
120-
} else if self.dynamicType === NSMutableArray.self {
120+
} else if type(of: self) === NSMutableArray.self {
121121
let array = NSArray()
122122
array._storage = self._storage
123123
return array
@@ -130,7 +130,7 @@ public class NSArray : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NS
130130
}
131131

132132
public func mutableCopy(with zone: NSZone? = nil) -> AnyObject {
133-
if self.dynamicType === NSArray.self || self.dynamicType === NSMutableArray.self {
133+
if type(of: self) === NSArray.self || type(of: self) === NSMutableArray.self {
134134
// always create and return an NSMutableArray
135135
let mutableArray = NSMutableArray()
136136
mutableArray._storage = self._storage
@@ -178,7 +178,7 @@ public class NSArray : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NS
178178
}
179179

180180
internal var allObjects: [AnyObject] {
181-
if self.dynamicType === NSArray.self || self.dynamicType === NSMutableArray.self {
181+
if type(of: self) === NSArray.self || type(of: self) === NSMutableArray.self {
182182
return _storage
183183
} else {
184184
return (0..<count).map { idx in
@@ -261,7 +261,7 @@ public class NSArray : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NS
261261
internal func getObjects(_ objects: inout [AnyObject], range: NSRange) {
262262
objects.reserveCapacity(objects.count + range.length)
263263

264-
if self.dynamicType === NSArray.self || self.dynamicType === NSMutableArray.self {
264+
if type(of: self) === NSArray.self || type(of: self) === NSMutableArray.self {
265265
objects += _storage[range.toRange()!]
266266
return
267267
}
@@ -646,7 +646,7 @@ public class NSMutableArray : NSArray {
646646
}
647647

648648
public func insert(_ anObject: AnyObject, at index: Int) {
649-
guard self.dynamicType === NSMutableArray.self else {
649+
guard type(of: self) === NSMutableArray.self else {
650650
NSRequiresConcreteImplementation()
651651
}
652652
_storage.insert(anObject, at: index)
@@ -659,14 +659,14 @@ public class NSMutableArray : NSArray {
659659
}
660660

661661
public func removeObject(at index: Int) {
662-
guard self.dynamicType === NSMutableArray.self else {
662+
guard type(of: self) === NSMutableArray.self else {
663663
NSRequiresConcreteImplementation()
664664
}
665665
_storage.remove(at: index)
666666
}
667667

668668
public func replaceObject(at index: Int, with anObject: AnyObject) {
669-
guard self.dynamicType === NSMutableArray.self else {
669+
guard type(of: self) === NSMutableArray.self else {
670670
NSRequiresConcreteImplementation()
671671
}
672672
let min = index
@@ -681,7 +681,7 @@ public class NSMutableArray : NSArray {
681681
public init(capacity numItems: Int) {
682682
super.init(objects: [], count: 0)
683683

684-
if self.dynamicType === NSMutableArray.self {
684+
if type(of: self) === NSMutableArray.self {
685685
_storage.reserveCapacity(numItems)
686686
}
687687
}
@@ -703,7 +703,7 @@ public class NSMutableArray : NSArray {
703703
}
704704

705705
public func addObjectsFromArray(_ otherArray: [AnyObject]) {
706-
if self.dynamicType === NSMutableArray.self {
706+
if type(of: self) === NSMutableArray.self {
707707
_storage += otherArray
708708
} else {
709709
for obj in otherArray {
@@ -713,15 +713,15 @@ public class NSMutableArray : NSArray {
713713
}
714714

715715
public func exchangeObject(at idx1: Int, withObjectAt idx2: Int) {
716-
if self.dynamicType === NSMutableArray.self {
716+
if type(of: self) === NSMutableArray.self {
717717
swap(&_storage[idx1], &_storage[idx2])
718718
} else {
719719
NSUnimplemented()
720720
}
721721
}
722722

723723
public func removeAllObjects() {
724-
if self.dynamicType === NSMutableArray.self {
724+
if type(of: self) === NSMutableArray.self {
725725
_storage.removeAll()
726726
} else {
727727
while count > 0 {
@@ -768,7 +768,7 @@ public class NSMutableArray : NSArray {
768768
}
769769

770770
public func removeObjects(in range: NSRange) {
771-
if self.dynamicType === NSMutableArray.self {
771+
if type(of: self) === NSMutableArray.self {
772772
_storage.removeSubrange(range.toRange()!)
773773
} else {
774774
for idx in range.toRange()!.reversed() {
@@ -783,7 +783,7 @@ public class NSMutableArray : NSArray {
783783
}
784784

785785
public func replaceObjectsInRange(_ range: NSRange, withObjectsFromArray otherArray: [AnyObject]) {
786-
if self.dynamicType === NSMutableArray.self {
786+
if type(of: self) === NSMutableArray.self {
787787
_storage.reserveCapacity(count - range.length + otherArray.count)
788788
for idx in 0..<range.length {
789789
_storage[idx + range.location] = otherArray[idx]
@@ -797,7 +797,7 @@ public class NSMutableArray : NSArray {
797797
}
798798

799799
public func setArray(_ otherArray: [AnyObject]) {
800-
if self.dynamicType === NSMutableArray.self {
800+
if type(of: self) === NSMutableArray.self {
801801
_storage = otherArray
802802
} else {
803803
replaceObjectsInRange(NSMakeRange(0, count), withObjectsFromArray: otherArray)
@@ -807,7 +807,7 @@ public class NSMutableArray : NSArray {
807807
public func insertObjects(_ objects: [AnyObject], atIndexes indexes: IndexSet) {
808808
precondition(objects.count == indexes.count)
809809

810-
if self.dynamicType === NSMutableArray.self {
810+
if type(of: self) === NSMutableArray.self {
811811
_storage.reserveCapacity(count + indexes.count)
812812
}
813813

Foundation/NSCharacterSet.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,9 @@ public class NSCharacterSet : NSObject, NSCopying, NSMutableCopying, NSCoding {
173173
}
174174

175175
public func longCharacterIsMember(_ theLongChar: UInt32) -> Bool {
176-
if self.dynamicType == NSCharacterSet.self || self.dynamicType == NSMutableCharacterSet.self {
176+
if type(of: self) == NSCharacterSet.self || type(of: self) == NSMutableCharacterSet.self {
177177
return _CFCharacterSetIsLongCharacterMember(unsafeBitCast(self, to: CFType.self), theLongChar)
178-
} else if self.dynamicType == _NSCFCharacterSet.self {
178+
} else if type(of: self) == _NSCFCharacterSet.self {
179179
return CFCharacterSetIsLongCharacterMember(_cfObject, theLongChar)
180180
} else {
181181
NSRequiresConcreteImplementation()
@@ -195,9 +195,9 @@ public class NSCharacterSet : NSObject, NSCopying, NSMutableCopying, NSCoding {
195195
}
196196

197197
public func copy(with zone: NSZone? = nil) -> AnyObject {
198-
if self.dynamicType == NSCharacterSet.self || self.dynamicType == NSMutableCharacterSet.self {
198+
if type(of: self) == NSCharacterSet.self || type(of: self) == NSMutableCharacterSet.self {
199199
return _CFCharacterSetCreateCopy(kCFAllocatorSystemDefault, self._cfObject)
200-
} else if self.dynamicType == _NSCFCharacterSet.self {
200+
} else if type(of: self) == _NSCFCharacterSet.self {
201201
return CFCharacterSetCreateCopy(kCFAllocatorSystemDefault, self._cfObject)
202202
} else {
203203
NSRequiresConcreteImplementation()
@@ -209,9 +209,9 @@ public class NSCharacterSet : NSObject, NSCopying, NSMutableCopying, NSCoding {
209209
}
210210

211211
public func mutableCopy(with zone: NSZone? = nil) -> AnyObject {
212-
if self.dynamicType == NSCharacterSet.self || self.dynamicType == NSMutableCharacterSet.self {
212+
if type(of: self) == NSCharacterSet.self || type(of: self) == NSMutableCharacterSet.self {
213213
return _CFCharacterSetCreateMutableCopy(kCFAllocatorSystemDefault, _cfObject)._nsObject
214-
} else if self.dynamicType == _NSCFCharacterSet.self {
214+
} else if type(of: self) == _NSCFCharacterSet.self {
215215
return CFCharacterSetCreateMutableCopy(kCFAllocatorSystemDefault, _cfObject)._nsObject
216216
} else {
217217
NSRequiresConcreteImplementation()

Foundation/NSData.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public class NSData : NSObject, NSCopying, NSMutableCopying, NSSecureCoding {
8282
private var _bytes: UnsafeMutablePointer<UInt8>? = nil
8383

8484
internal var _cfObject: CFType {
85-
if self.dynamicType === NSData.self || self.dynamicType === NSMutableData.self {
85+
if type(of: self) === NSData.self || type(of: self) === NSMutableData.self {
8686
return unsafeBitCast(self, to: CFType.self)
8787
} else {
8888
let bytePtr = self.bytes.bindMemory(to: UInt8.self, capacity: self.length)
@@ -111,14 +111,14 @@ public class NSData : NSObject, NSCopying, NSMutableCopying, NSSecureCoding {
111111
if let allocatedBytes = _bytes {
112112
_deallocHandler?.handler(allocatedBytes, _length)
113113
}
114-
if self.dynamicType === NSData.self || self.dynamicType === NSMutableData.self {
114+
if type(of: self) === NSData.self || type(of: self) === NSMutableData.self {
115115
_CFDeinit(self._cfObject)
116116
}
117117
}
118118

119119
internal init(bytes: UnsafeMutableRawPointer?, length: Int, copy: Bool, deallocator: ((UnsafeMutableRawPointer, Int) -> Void)?) {
120120
super.init()
121-
let options : CFOptionFlags = (self.dynamicType == NSMutableData.self) ? __kCFMutable | __kCFGrowable : 0x0
121+
let options : CFOptionFlags = (type(of: self) == NSMutableData.self) ? __kCFMutable | __kCFGrowable : 0x0
122122
let bytePtr = bytes?.bindMemory(to: UInt8.self, capacity: length)
123123
if copy {
124124
_CFDataInit(unsafeBitCast(self, to: CFMutableData.self), options, length, bytePtr, length, false)
@@ -174,7 +174,7 @@ public class NSData : NSObject, NSCopying, NSMutableCopying, NSSecureCoding {
174174
} else {
175175
return nil
176176
}
177-
} else if aDecoder.dynamicType == NSKeyedUnarchiver.self || aDecoder.containsValue(forKey: "NS.data") {
177+
} else if type(of: aDecoder) == NSKeyedUnarchiver.self || aDecoder.containsValue(forKey: "NS.data") {
178178
guard let data = aDecoder._decodePropertyListForKey("NS.data") as? NSData else {
179179
return nil
180180
}

0 commit comments

Comments
 (0)