Skip to content

Commit a4230ab

Browse files
[stdlib] Update stdlib to 4.0 and reorganize compatibility shims (#17580)
* Update stdlib to 4.0 and move all compatibility shims into a dedicated source file
1 parent 109829b commit a4230ab

File tree

72 files changed

+1381
-1818
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+1381
-1818
lines changed

cmake/modules/SwiftSource.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,9 @@ function(_compile_swift_files
257257
"-Xfrontend" "${GROUP_INFO_JSON_FILE}")
258258
endif()
259259

260-
# Force swift 3 compatibility mode for Standard Library.
260+
# Force swift 4 compatibility mode for Standard Library.
261261
if (SWIFTFILE_IS_STDLIB)
262-
list(APPEND swift_flags "-swift-version" "3")
262+
list(APPEND swift_flags "-swift-version" "4")
263263
endif()
264264

265265
# Force swift 4 compatibility mode for overlays.

stdlib/private/StdlibUnittest/MinimalTypes.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ public var GenericMinimalHashableValue_equalImpl =
220220
fatalError("GenericMinimalHashableValue_equalImpl is not set yet")
221221
})
222222
public var GenericMinimalHashableValue_hashIntoImpl =
223-
ResettableValue<(Any, inout Hasher) -> Void>({ _ in
223+
ResettableValue<(Any, inout Hasher) -> Void>({ (_,_) in
224224
fatalError("GenericMinimalHashableValue_hashIntoImpl is not set yet")
225225
})
226226

@@ -276,7 +276,7 @@ public var GenericMinimalHashableClass_equalImpl =
276276
fatalError("GenericMinimalHashableClass_equalImpl is not set yet")
277277
})
278278
public var GenericMinimalHashableClass_hashIntoImpl =
279-
ResettableValue<(Any, inout Hasher) -> Void>({ _ in
279+
ResettableValue<(Any, inout Hasher) -> Void>({ (_,_) in
280280
fatalError("GenericMinimalHashableClass_hashIntoImpl is not set yet")
281281
})
282282

stdlib/private/StdlibUnittest/StdlibUnittest.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1775,15 +1775,15 @@ public func _parseDottedVersionTriple(_ s: String) -> (Int, Int, Int) {
17751775
}
17761776

17771777
func _getOSVersion() -> OSVersion {
1778-
#if os(iOS) && (arch(i386) || arch(x86_64))
1778+
#if os(iOS) && targetEnvironment(simulator)
17791779
// On simulator, the plist file that we try to read turns out to be host's
17801780
// plist file, which indicates OS X.
17811781
//
17821782
// FIXME: how to get the simulator version *without* UIKit?
17831783
return .iOSSimulator
1784-
#elseif os(tvOS) && (arch(i386) || arch(x86_64))
1784+
#elseif os(tvOS) && targetEnvironment(simulator)
17851785
return .tvOSSimulator
1786-
#elseif os(watchOS) && (arch(i386) || arch(x86_64))
1786+
#elseif os(watchOS) && targetEnvironment(simulator)
17871787
return .watchOSSimulator
17881788
#elseif os(Linux)
17891789
return .linux

stdlib/public/SDK/AppKit/AppKit.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import Foundation
1414
@_exported import AppKit
1515

16-
extension NSCursor : _DefaultCustomPlaygroundQuickLookable {
16+
extension NSCursor : __DefaultCustomPlaygroundQuickLookable {
1717
@available(*, deprecated, message: "NSCursor._defaultCustomPlaygroundQuickLook will be removed in a future Swift version")
1818
public var _defaultCustomPlaygroundQuickLook: PlaygroundQuickLook {
1919
return .image(image)
@@ -24,7 +24,7 @@ internal struct _NSViewQuickLookState {
2424
static var views = Set<NSView>()
2525
}
2626

27-
extension NSView : _DefaultCustomPlaygroundQuickLookable {
27+
extension NSView : __DefaultCustomPlaygroundQuickLookable {
2828
@available(*, deprecated, message: "NSView._defaultCustomPlaygroundQuickLook will be removed in a future Swift version")
2929
public var _defaultCustomPlaygroundQuickLook: PlaygroundQuickLook {
3030
// if you set NSView.needsDisplay, you can get yourself in a recursive scenario where the same view

stdlib/public/SDK/CoreGraphics/CoreGraphics.swift

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,11 +228,13 @@ public extension CGPoint {
228228
}
229229
}
230230

231-
extension CGPoint : CustomReflectable, CustomPlaygroundQuickLookable {
231+
extension CGPoint : CustomReflectable {
232232
public var customMirror: Mirror {
233233
return Mirror(self, children: ["x": x, "y": y], displayStyle: .`struct`)
234234
}
235+
}
235236

237+
extension CGPoint : _CustomPlaygroundQuickLookable {
236238
@available(*, deprecated, message: "CGPoint.customPlaygroundQuickLook will be removed in a future Swift version")
237239
public var customPlaygroundQuickLook: PlaygroundQuickLook {
238240
return .point(Double(x), Double(y))
@@ -293,14 +295,16 @@ public extension CGSize {
293295
}
294296
}
295297

296-
extension CGSize : CustomReflectable, CustomPlaygroundQuickLookable {
298+
extension CGSize : CustomReflectable {
297299
public var customMirror: Mirror {
298300
return Mirror(
299301
self,
300302
children: ["width": width, "height": height],
301303
displayStyle: .`struct`)
302304
}
305+
}
303306

307+
extension CGSize : _CustomPlaygroundQuickLookable {
304308
@available(*, deprecated, message: "CGSize.customPlaygroundQuickLook will be removed in a future Swift version")
305309
public var customPlaygroundQuickLook: PlaygroundQuickLook {
306310
return .size(Double(width), Double(height))
@@ -431,14 +435,16 @@ public extension CGRect {
431435
public var y: CGFloat { return minY }
432436
}
433437

434-
extension CGRect : CustomReflectable, CustomPlaygroundQuickLookable {
438+
extension CGRect : CustomReflectable {
435439
public var customMirror: Mirror {
436440
return Mirror(
437441
self,
438442
children: ["origin": origin, "size": size],
439443
displayStyle: .`struct`)
440444
}
445+
}
441446

447+
extension CGRect : _CustomPlaygroundQuickLookable {
442448
@available(*, deprecated, message: "CGRect.customPlaygroundQuickLook will be removed in a future Swift version")
443449
public var customPlaygroundQuickLook: PlaygroundQuickLook {
444450
return .rectangle(

stdlib/public/SDK/Foundation/Date.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ extension NSDate : _HasCustomAnyHashableRepresentation {
272272
}
273273
}
274274

275-
extension Date : CustomPlaygroundQuickLookable {
275+
extension Date : _CustomPlaygroundQuickLookable {
276276
var summary: String {
277277
let df = DateFormatter()
278278
df.dateStyle = .medium

stdlib/public/SDK/Foundation/NSCoder.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ extension NSKeyedUnarchiver {
172172
@available(macOS 10.13, iOS 11.0, watchOS 4.0, tvOS 11.0, *)
173173
public static func unarchivedObject<DecodedObjectType>(ofClass cls: DecodedObjectType.Type, from data: Data) throws -> DecodedObjectType? where DecodedObjectType : NSCoding, DecodedObjectType : NSObject {
174174
var error: NSError?
175-
let result = __NSKeyedUnarchiverSecureUnarchiveObjectOfClass(cls as! AnyClass, data, &error)
175+
let result = __NSKeyedUnarchiverSecureUnarchiveObjectOfClass(cls as AnyClass, data, &error)
176176
try resolveError(error)
177177
return result as? DecodedObjectType
178178
}

stdlib/public/SDK/Foundation/NSDate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
@_exported import Foundation // Clang module
1414

15-
extension NSDate : CustomPlaygroundQuickLookable {
15+
extension NSDate : _CustomPlaygroundQuickLookable {
1616
@nonobjc
1717
var summary: String {
1818
let df = DateFormatter()

stdlib/public/SDK/Foundation/NSRange.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ extension NSRange : CustomReflectable {
197197
}
198198
}
199199

200-
extension NSRange : CustomPlaygroundQuickLookable {
200+
extension NSRange : _CustomPlaygroundQuickLookable {
201201
@available(*, deprecated, message: "NSRange.customPlaygroundQuickLook will be removed in a future Swift version")
202202
public var customPlaygroundQuickLook: PlaygroundQuickLook {
203203
return .range(Int64(location), Int64(length))

stdlib/public/SDK/Foundation/NSString.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ extension NSString {
107107
}
108108
}
109109

110-
extension NSString : CustomPlaygroundQuickLookable {
110+
extension NSString : _CustomPlaygroundQuickLookable {
111111
@available(*, deprecated, message: "NSString.customPlaygroundQuickLook will be removed in a future Swift version")
112112
public var customPlaygroundQuickLook: PlaygroundQuickLook {
113113
return .text(self as String)

0 commit comments

Comments
 (0)