Skip to content

Commit bdd4cef

Browse files
authored
Merge pull request #1040 from ikesyo/address-warnings
2 parents 697accb + 6238a78 commit bdd4cef

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

Foundation/CharacterSet.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ public struct CharacterSet : ReferenceConvertible, Equatable, Hashable, SetAlgeb
486486

487487
@_semantics("convertToObjectiveC")
488488
public func _bridgeToObjectiveC() -> NSCharacterSet {
489-
return unsafeBitCast(_wrapped, to: NSCharacterSet.self)
489+
return _wrapped
490490
}
491491

492492
public static func _forceBridgeFromObjectiveC(_ input: NSCharacterSet, result: inout CharacterSet?) {

Foundation/NSURLProtocol.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ internal class _ProtocolClient : NSObject, URLProtocolClient {
164164
case .noDelegate:
165165
task.state = .completed
166166
session.taskRegistry.remove(task)
167-
case .dataCompletionHandler(let completion):
167+
case .dataCompletionHandler:
168168
let data = Data()
169169
guard let client = `protocol`.client else { fatalError() }
170170
client.urlProtocol(`protocol`, didLoad: data)

Foundation/NSURLSession/http/HTTPURLProtocol.swift

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ extension _HTTPURLProtocol {
682682
return
683683
}
684684

685-
if case .toFile(let url, let fileHandle?) = bodyDataDrain {
685+
if case .toFile(_, let fileHandle?) = bodyDataDrain {
686686
fileHandle.closeFile()
687687
}
688688
self.client?.urlProtocolDidFinishLoading(self)
@@ -709,7 +709,7 @@ extension _HTTPURLProtocol {
709709
fatalError("Trying to redirect, but the transfer is not complete.")
710710
}
711711

712-
let session = task?.session as! URLSession
712+
guard let session = task?.session as? URLSession else { fatalError() }
713713
switch session.behaviour(for: task!) {
714714
case .taskDelegate(let delegate):
715715
// At this point we need to change the internal state to note
@@ -724,9 +724,8 @@ extension _HTTPURLProtocol {
724724

725725
self.internalState = .waitingForRedirectCompletionHandler(response: response, bodyDataDrain: bodyDataDrain)
726726
// We need this ugly cast in order to be able to support `URLSessionTask.init()`
727-
guard let s = session as? URLSession else { fatalError() }
728-
s.delegateQueue.addOperation {
729-
delegate.urlSession(s, task: self.task!, willPerformHTTPRedirection: response as! HTTPURLResponse, newRequest: request) { [weak self] (request: URLRequest?) in
727+
session.delegateQueue.addOperation {
728+
delegate.urlSession(session, task: self.task!, willPerformHTTPRedirection: response as! HTTPURLResponse, newRequest: request) { [weak self] (request: URLRequest?) in
730729
guard let task = self else { return }
731730
self?.task?.workQueue.async {
732731
task.didCompleteRedirectCallback(request)
@@ -763,7 +762,7 @@ internal extension _HTTPURLProtocol {
763762
guard let dt = task as? URLSessionDataTask else { return }
764763
guard case .transferInProgress(let ts) = self.internalState else { fatalError("Transfer not in progress.") }
765764
guard let response = ts.response else { fatalError("Header complete, but not URL response.") }
766-
let session = task?.session as! URLSession
765+
guard let session = task?.session as? URLSession else { fatalError() }
767766
switch session.behaviour(for: self.task!) {
768767
case .noDelegate:
769768
break
@@ -774,13 +773,12 @@ internal extension _HTTPURLProtocol {
774773
//
775774
// For now, we'll notify the delegate, but won't pause the transfer,
776775
// and we'll disregard the completion handler:
777-
guard let s = session as? URLSession else { fatalError() }
778776
switch response.statusCode {
779777
case 301, 302, 303, 307:
780778
break
781779
default:
782-
s.delegateQueue.addOperation {
783-
delegate.urlSession(s, dataTask: dt, didReceive: response, completionHandler: { _ in
780+
session.delegateQueue.addOperation {
781+
delegate.urlSession(session, dataTask: dt, didReceive: response, completionHandler: { _ in
784782
URLSession.printDebug("warning: Ignoring disposition from completion handler.")
785783
})
786784
}

0 commit comments

Comments
 (0)