Skip to content

Commit 7fc8d97

Browse files
committed
Minor update for SE-0089
1 parent 541f035 commit 7fc8d97

8 files changed

+17
-17
lines changed

Foundation/NSBundle.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public class Bundle: NSObject {
6363
}
6464

6565
override public var description: String {
66-
return "\(String(Bundle.self)) <\(bundleURL.path!)> (\(isLoaded ? "loaded" : "not yet loaded"))"
66+
return "\(String(describing: Bundle.self)) <\(bundleURL.path!)> (\(isLoaded ? "loaded" : "not yet loaded"))"
6767
}
6868

6969

Foundation/NSHost.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public class Host: NSObject {
9494
let lookupInfo = { (content: inout [String], flags: Int32) in
9595
let hname = UnsafeMutablePointer<Int8>.allocate(capacity: 1024)
9696
if (getnameinfo(info.ai_addr, sa_len, hname, 1024, nil, 0, flags) == 0) {
97-
content.append(String(hname))
97+
content.append(String(describing: hname))
9898
}
9999
hname.deinitialize()
100100
hname.deallocate(capacity: 1024)

Foundation/NSJSONSerialization.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ private struct JSONReader {
599599
}
600600

601601
if !UTF16.isLeadSurrogate(codeUnit) {
602-
return (String(UnicodeScalar(codeUnit)), index)
602+
return (String(UnicodeScalar(codeUnit)!), index)
603603
}
604604

605605
guard let (trailCodeUnit, finalIndex) = try consumeASCIISequence("\\u", input: index).flatMap(parseCodeUnit) , UTF16.isTrailSurrogate(trailCodeUnit) else {
@@ -610,7 +610,7 @@ private struct JSONReader {
610610

611611
let highValue = (UInt32(codeUnit - 0xD800) << 10)
612612
let lowValue = UInt32(trailCodeUnit - 0xDC00)
613-
return (String(UnicodeScalar(highValue + lowValue + 0x10000)), finalIndex)
613+
return (String(UnicodeScalar(highValue + lowValue + 0x10000)!), finalIndex)
614614
}
615615

616616
func isHexChr(_ byte: UInt8) -> Bool {

Foundation/NSKeyedArchiver.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -238,14 +238,14 @@ public class NSKeyedArchiver : NSCoder {
238238
}
239239

240240
public class func setClassName(_ codedName: String?, for cls: AnyClass) {
241-
let clsName = String(cls.dynamicType)
241+
let clsName = String(describing: cls.dynamicType)
242242
_classNameMapLock.synchronized {
243243
_classNameMap[clsName] = codedName
244244
}
245245
}
246246

247247
public func setClassName(_ codedName: String?, for cls: AnyClass) {
248-
let clsName = String(cls.dynamicType)
248+
let clsName = String(describing: cls.dynamicType)
249249
_classNameMap[clsName] = codedName
250250
}
251251

Foundation/NSObjCRuntime.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ public func NSStringFromClass(_ aClass: AnyClass) -> String {
258258
if components[0] == _SwiftFoundationModuleName {
259259
return components[1]
260260
} else {
261-
return String(aClassName)
261+
return String(describing: aClassName)
262262
}
263263
}
264264

Foundation/NSRegularExpression.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ extension RegularExpression {
225225
if currentRange.location > NSMaxRange(previousRange) {
226226
let min = start.advanced(by: NSMaxRange(previousRange))
227227
let max = start.advanced(by: currentRange.location)
228-
str += String(string.utf16[min..<max])
228+
str += String(string.utf16[min..<max])!
229229
}
230230
str += replacement
231231
previousRange = currentRange
@@ -234,7 +234,7 @@ extension RegularExpression {
234234
if length > NSMaxRange(previousRange) {
235235
let min = start.advanced(by: NSMaxRange(previousRange))
236236
let max = start.advanced(by: length)
237-
str += String(string.utf16[min..<max])
237+
str += String(string.utf16[min..<max])!
238238
}
239239

240240
return str
@@ -311,7 +311,7 @@ extension RegularExpression {
311311
let start = string.utf16.startIndex
312312
let min = start.advanced(by: substringRange.location)
313313
let max = start.advanced(by: substringRange.location + substringRange.length)
314-
substring = String(string.utf16[min..<max])
314+
substring = String(string.utf16[min..<max])!
315315
}
316316
str.replaceCharacters(in: rangeToReplace, with: substring)
317317

Foundation/NSString.swift

+5-5
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ public class NSString : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, N
311311
}
312312

313313
public required init(stringLiteral value: StaticString) {
314-
_storage = String(value)
314+
_storage = String(describing: value)
315315
}
316316

317317
internal var _fastCStringContents: UnsafePointer<Int8>? {
@@ -366,7 +366,7 @@ extension NSString {
366366

367367
public func substring(from: Int) -> String {
368368
if self.dynamicType == NSString.self || self.dynamicType == NSMutableString.self {
369-
return String(_storage.utf16.suffix(from: _storage.utf16.startIndex.advanced(by: from)))
369+
return String(_storage.utf16.suffix(from: _storage.utf16.startIndex.advanced(by: from)))!
370370
} else {
371371
return substring(with: NSMakeRange(from, length - from))
372372
}
@@ -375,7 +375,7 @@ extension NSString {
375375
public func substring(to: Int) -> String {
376376
if self.dynamicType == NSString.self || self.dynamicType == NSMutableString.self {
377377
return String(_storage.utf16.prefix(upTo: _storage.utf16.startIndex
378-
.advanced(by: to)))
378+
.advanced(by: to)))!
379379
} else {
380380
return substring(with: NSMakeRange(0, to))
381381
}
@@ -386,11 +386,11 @@ extension NSString {
386386
let start = _storage.utf16.startIndex
387387
let min = start.advanced(by: range.location)
388388
let max = start.advanced(by: range.location + range.length)
389-
return String(_storage.utf16[min..<max])
389+
return String(_storage.utf16[min..<max])!
390390
} else {
391391
let buff = UnsafeMutablePointer<unichar>.allocate(capacity: range.length)
392392
getCharacters(buff, range: range)
393-
let result = String(buff)
393+
let result = String(describing: buff)
394394
buff.deinitialize()
395395
buff.deallocate(capacity: range.length)
396396
return result

Foundation/NSXMLParser.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ internal func _NSXMLParserExternalEntityWithURL(_ interface: _CFXMLInterface, ur
6161
let policy = parser.externalEntityResolvingPolicy
6262
var a: URL?
6363
if let allowedEntityURLs = parser.allowedExternalEntityURLs {
64-
if let url = URL(string: String(urlStr)) {
64+
if let url = URL(string: String(describing: urlStr)) {
6565
a = url
6666
if let scheme = url.scheme {
6767
if scheme == "file" {
@@ -84,7 +84,7 @@ internal func _NSXMLParserExternalEntityWithURL(_ interface: _CFXMLInterface, ur
8484
guard let url = parser._url else { break }
8585

8686
if a == nil {
87-
a = URL(string: String(urlStr))
87+
a = URL(string: String(describing: urlStr))
8888
}
8989

9090
guard let aUrl = a else { break }

0 commit comments

Comments
 (0)