Skip to content

Commit 22fc7f4

Browse files
authored
Merge pull request swiftlang#1022 from spevans/pr_swift4_only
2 parents 37927d3 + 9980d4a commit 22fc7f4

File tree

10 files changed

+44
-40
lines changed

10 files changed

+44
-40
lines changed

Foundation.xcodeproj/project.pbxproj

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2616,15 +2616,15 @@
26162616
r,
26172617
r,
26182618
);
2619-
OTHER_SWIFT_FLAGS = "-DDEPLOYMENT_ENABLE_LIBDISPATCH -DDEPLOYMENT_RUNTIME_SWIFT -swift-version 3";
2619+
OTHER_SWIFT_FLAGS = "-DDEPLOYMENT_ENABLE_LIBDISPATCH -DDEPLOYMENT_RUNTIME_SWIFT -swift-version 4";
26202620
PRODUCT_BUNDLE_IDENTIFIER = org.swift.Foundation;
26212621
PRODUCT_NAME = "$(TARGET_NAME)";
26222622
SKIP_INSTALL = YES;
26232623
SWIFT_INDEX_STORE_ENABLE = NO;
26242624
SWIFT_INSTALL_OBJC_HEADER = NO;
26252625
SWIFT_OBJC_INTERFACE_HEADER_NAME = "";
26262626
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
2627-
SWIFT_VERSION = 3.0;
2627+
SWIFT_VERSION = 4.0;
26282628
};
26292629
name = Debug;
26302630
};
@@ -2689,14 +2689,14 @@
26892689
r,
26902690
r,
26912691
);
2692-
OTHER_SWIFT_FLAGS = "-DDEPLOYMENT_ENABLE_LIBDISPATCH -DDEPLOYMENT_RUNTIME_SWIFT -swift-version 3";
2692+
OTHER_SWIFT_FLAGS = "-DDEPLOYMENT_ENABLE_LIBDISPATCH -DDEPLOYMENT_RUNTIME_SWIFT -swift-version 4";
26932693
PRODUCT_BUNDLE_IDENTIFIER = org.swift.Foundation;
26942694
PRODUCT_NAME = "$(TARGET_NAME)";
26952695
SKIP_INSTALL = YES;
26962696
SWIFT_INDEX_STORE_ENABLE = NO;
26972697
SWIFT_INSTALL_OBJC_HEADER = NO;
26982698
SWIFT_OBJC_INTERFACE_HEADER_NAME = "";
2699-
SWIFT_VERSION = 3.0;
2699+
SWIFT_VERSION = 4.0;
27002700
};
27012701
name = Release;
27022702
};
@@ -2738,7 +2738,7 @@
27382738
PRIVATE_HEADERS_FOLDER_PATH = /usr/local/include/CoreFoundation;
27392739
PRODUCT_NAME = "$(TARGET_NAME)";
27402740
PUBLIC_HEADERS_FOLDER_PATH = /usr/local/include/CoreFoundation;
2741-
SWIFT_VERSION = 3.0;
2741+
SWIFT_VERSION = 4.0;
27422742
};
27432743
name = Debug;
27442744
};
@@ -2780,7 +2780,7 @@
27802780
PRIVATE_HEADERS_FOLDER_PATH = /usr/local/include/CoreFoundation;
27812781
PRODUCT_NAME = "$(TARGET_NAME)";
27822782
PUBLIC_HEADERS_FOLDER_PATH = /usr/local/include/CoreFoundation;
2783-
SWIFT_VERSION = 3.0;
2783+
SWIFT_VERSION = 4.0;
27842784
};
27852785
name = Release;
27862786
};
@@ -2800,12 +2800,12 @@
28002800
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
28012801
LIBRARY_SEARCH_PATHS = "$(inherited)";
28022802
MACH_O_TYPE = mh_execute;
2803-
OTHER_SWIFT_FLAGS = "-DDEPLOYMENT_ENABLE_LIBDISPATCH -swift-version 3";
2803+
OTHER_SWIFT_FLAGS = "-DDEPLOYMENT_ENABLE_LIBDISPATCH -swift-version 4";
28042804
PRODUCT_BUNDLE_IDENTIFIER = org.swift.TestFoundation;
28052805
PRODUCT_NAME = "$(TARGET_NAME)";
28062806
SKIP_INSTALL = YES;
28072807
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
2808-
SWIFT_VERSION = 3.0;
2808+
SWIFT_VERSION = 4.0;
28092809
WRAPPER_EXTENSION = app;
28102810
};
28112811
name = Debug;
@@ -2826,11 +2826,11 @@
28262826
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
28272827
LIBRARY_SEARCH_PATHS = "$(inherited)";
28282828
MACH_O_TYPE = mh_execute;
2829-
OTHER_SWIFT_FLAGS = "-DDEPLOYMENT_ENABLE_LIBDISPATCH -swift-version 3";
2829+
OTHER_SWIFT_FLAGS = "-DDEPLOYMENT_ENABLE_LIBDISPATCH -swift-version 4";
28302830
PRODUCT_BUNDLE_IDENTIFIER = org.swift.TestFoundation;
28312831
PRODUCT_NAME = "$(TARGET_NAME)";
28322832
SKIP_INSTALL = YES;
2833-
SWIFT_VERSION = 3.0;
2833+
SWIFT_VERSION = 4.0;
28342834
WRAPPER_EXTENSION = app;
28352835
};
28362836
name = Release;
@@ -2885,7 +2885,7 @@
28852885
HEADER_SEARCH_PATHS = "$(CONFIGURATION_BUILD_DIR)/usr/local/include";
28862886
PRODUCT_NAME = "$(TARGET_NAME)";
28872887
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
2888-
SWIFT_VERSION = 3.0;
2888+
SWIFT_VERSION = 4.0;
28892889
};
28902890
name = Debug;
28912891
};
@@ -2896,7 +2896,7 @@
28962896
CLANG_ENABLE_OBJC_ARC = YES;
28972897
HEADER_SEARCH_PATHS = "$(CONFIGURATION_BUILD_DIR)/usr/local/include";
28982898
PRODUCT_NAME = "$(TARGET_NAME)";
2899-
SWIFT_VERSION = 3.0;
2899+
SWIFT_VERSION = 4.0;
29002900
};
29012901
name = Release;
29022902
};

Foundation/NSArray.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ open class NSArray : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NSCo
381381
ptr.advanced(by: idx).pointee = Int32(hash).littleEndian
382382
}
383383
}
384-
return Data(bytesNoCopy: buffer, count: size, deallocator: .custom({ _ in
384+
return Data(bytesNoCopy: buffer, count: size, deallocator: .custom({ (_, _) in
385385
buffer.deallocate(capacity: size)
386386
}))
387387
}

Foundation/NSError.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ open class NSError : NSObject, NSCopying, NSSecureCoding, NSCoding {
7070
if let info = aDecoder.decodeObject(of: [NSSet.self, NSDictionary.self, NSArray.self, NSString.self, NSNumber.self, NSData.self, NSURL.self], forKey: "NSUserInfo") as? NSDictionary {
7171
var filteredUserInfo = [String : Any]()
7272
// user info must be filtered so that the keys are all strings
73-
info.enumerateKeysAndObjects(options: []) {
74-
if let key = $0.0 as? NSString {
75-
filteredUserInfo[key._swiftObject] = $0.1
73+
info.enumerateKeysAndObjects({ (key, value, _) in
74+
if let key = key as? NSString {
75+
filteredUserInfo[key._swiftObject] = value
7676
}
77-
}
77+
})
7878
_userInfo = filteredUserInfo
7979
}
8080
}

Foundation/NSIndexSet.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ open class NSIndexSet : NSObject, NSCopying, NSMutableCopying, NSSecureCoding {
9393

9494
open func mutableCopy(with zone: NSZone? = nil) -> Any {
9595
let set = NSMutableIndexSet()
96-
enumerateRanges(options: []) {
97-
set.add(in: $0.0)
96+
enumerateRanges(options: []) { (range, _) in
97+
set.add(in: range)
9898
}
9999
return set
100100
}
@@ -400,7 +400,7 @@ open class NSIndexSet : NSObject, NSCopying, NSMutableCopying, NSSecureCoding {
400400
lock.unlock()
401401
if stop { return }
402402

403-
let idx = rangeSequence.index(rangeSequence.startIndex, offsetBy: IntMax(rangeIdx))
403+
let idx = rangeSequence.index(rangeSequence.startIndex, offsetBy: Int64(rangeIdx))
404404
let curRange = rangeSequence[idx]
405405
let intersection = NSIntersectionRange(curRange, range)
406406
if passRanges {

Foundation/NSNotificationQueue.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,16 +109,16 @@ open class NotificationQueue: NSObject {
109109
var predicate: (NSNotificationListEntry) -> Bool
110110
switch coalesceMask {
111111
case [.onName, .onSender]:
112-
predicate = { (entryNotification, _) in
113-
return _SwiftValue.store(notification.object) !== _SwiftValue.store(entryNotification.object) || notification.name != entryNotification.name
112+
predicate = { entry in
113+
return _SwiftValue.store(notification.object) !== _SwiftValue.store(entry.0.object) || notification.name != entry.0.name
114114
}
115115
case [.onName]:
116-
predicate = { (entryNotification, _) in
117-
return notification.name != entryNotification.name
116+
predicate = { entry in
117+
return notification.name != entry.0.name
118118
}
119119
case [.onSender]:
120-
predicate = { (entryNotification, _) in
121-
return _SwiftValue.store(notification.object) !== _SwiftValue.store(entryNotification.object)
120+
predicate = { entry in
121+
return _SwiftValue.store(notification.object) !== _SwiftValue.store(entry.0.object)
122122
}
123123
default:
124124
return

Foundation/NSURLSession/http/HTTPBodySource.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,13 @@ internal final class _HTTPBodyFileSource {
124124
var fileSystemRepresentation: UnsafePointer<Int8>! = nil
125125
fileURL.withUnsafeFileSystemRepresentation {
126126
fileSystemRepresentation = $0
127-
}
128-
self.channel = DispatchIO(type: .stream, path: fileSystemRepresentation, oflag: O_RDONLY, mode: 0, queue: workQueue, cleanupHandler: {_ in })
127+
}
128+
guard let channel = DispatchIO(type: .stream, path: fileSystemRepresentation,
129+
oflag: O_RDONLY, mode: 0, queue: workQueue,
130+
cleanupHandler: {_ in }) else {
131+
fatalError("Cant create DispatchIO channel")
132+
}
133+
self.channel = channel
129134
self.channel.setLimit(highWater: CFURLSessionMaxWriteSize)
130135
}
131136

Foundation/NSXMLNode.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -617,8 +617,8 @@ open class XMLNode: NSObject, NSCopying {
617617
if let parentNode = _CFXMLNodeGetParent(parent!) {
618618
let grandparent = XMLNode._objectNodeForNode(parentNode)
619619
let possibleParentNodes = grandparent.filter { $0.name == self.parent?.name }
620-
let count = possibleParentNodes.reduce(0) {
621-
return $0.0 + 1
620+
let count = possibleParentNodes.reduce(0) { (x, _) in
621+
return x + 1
622622
}
623623

624624
if count <= 1 {

TestFoundation/TestNSCompoundPredicate.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class TestNSCompoundPredicate: XCTestCase {
9292
var shortCircuited = true
9393

9494
let bOK = NSPredicate(value: false)
95-
let bDontEval = NSPredicate(block: { _ in
95+
let bDontEval = NSPredicate(block: { (_, _) in
9696
shortCircuited = false
9797
return true
9898
})
@@ -106,7 +106,7 @@ class TestNSCompoundPredicate: XCTestCase {
106106
var shortCircuited = true
107107

108108
let bOK = NSPredicate(value: true)
109-
let bDontEval = NSPredicate(block: { _ in
109+
let bDontEval = NSPredicate(block: { (_, _) in
110110
shortCircuited = false
111111
return true
112112
})

TestFoundation/TestNSURLSession.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ class TestURLSession : XCTestCase {
193193
let session = URLSession(configuration: URLSessionConfiguration.default,
194194
delegate: delegate, delegateQueue: nil)
195195
let completionExpectation = expectation(description: "dataTask completion block wasn't called")
196-
let task = session.dataTask(with: url) { _ in
196+
let task = session.dataTask(with: url) { (_, _, _) in
197197
completionExpectation.fulfill()
198198
}
199199
task.resume()
@@ -207,9 +207,8 @@ class TestURLSession : XCTestCase {
207207
delegate: nil,
208208
delegateQueue: nil)
209209
let completionExpectation = expectation(description: "dataTask completion block wasn't called")
210-
let task = session.dataTask(with: url) { result in
211-
let error = result.2 as? URLError
212-
210+
let task = session.dataTask(with: url) { (_, _, result) in
211+
let error = result as? URLError
213212
XCTAssertNotNil(error)
214213
XCTAssertEqual(error?.code, .badURL)
215214
completionExpectation.fulfill()

lib/phases.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@ def generate(self):
172172
generated += " -I" + Configuration.current.build_directory.path_by_appending(self.product.name).relative() + self.product.ROOT_HEADERS_FOLDER_PATH
173173
generated += " -I" + Configuration.current.build_directory.relative()
174174
swiftflags = TargetConditional.value(self.product.SWIFTCFLAGS)
175-
# Force building in Swift 3 compatibility mode.
176-
swiftflags += " -swift-version 3"
175+
# Force building in Swift 4 compatibility mode.
176+
swiftflags += " -swift-version 4"
177177
if swiftflags is not None:
178178
generated += " " + swiftflags
179179
return generated
@@ -431,10 +431,10 @@ def generate(self):
431431
if resource is None:
432432
continue
433433
swiftSources += " " + resource.relative()
434-
# Note: Fix -swift-version 3 for now.
434+
# Note: Fix -swift-version 4 for now.
435435
return """
436436
build """ + appName + """: SwiftExecutable """ + swiftSources + self.generate_dependencies(libDependencyName) + """
437-
flags = -swift-version 3 -I""" + Configuration.current.build_directory.path_by_appending(self.product.name).relative() + self.product.ROOT_HEADERS_FOLDER_PATH + " -I" + Configuration.current.build_directory.path_by_appending(self.product.name).relative() + " -L" + Configuration.current.build_directory.path_by_appending(self.product.name).relative() + " " + TargetConditional.value(self.product.SWIFTCFLAGS) + """
437+
flags = -swift-version 4 -I""" + Configuration.current.build_directory.path_by_appending(self.product.name).relative() + self.product.ROOT_HEADERS_FOLDER_PATH + " -I" + Configuration.current.build_directory.path_by_appending(self.product.name).relative() + " -L" + Configuration.current.build_directory.path_by_appending(self.product.name).relative() + " " + TargetConditional.value(self.product.SWIFTCFLAGS) + """
438438
build """ + self.executableName + """: phony | """ + appName + """
439439
"""
440440

0 commit comments

Comments
 (0)