Skip to content

Commit d54e56b

Browse files
authored
Merge pull request #40006 from lorentey/deninenineninenine-codable-additions
2 parents 544594b + 5f65686 commit d54e56b

File tree

4 files changed

+26
-25
lines changed

4 files changed

+26
-25
lines changed

stdlib/public/core/Codable.swift

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5535,33 +5535,34 @@ internal struct _DictionaryCodingKey: CodingKey {
55355535
/// and decoding `Dictionary` values keyed by the conforming type to and from
55365536
/// a keyed container, rather than encoding and decoding the dictionary as an
55375537
/// unkeyed container of alternating key-value pairs.
5538-
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
5538+
@available(SwiftStdlib 5.6, *)
55395539
public protocol CodingKeyRepresentable {
5540-
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
5540+
@available(SwiftStdlib 5.6, *)
55415541
var codingKey: CodingKey { get }
5542-
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
5542+
@available(SwiftStdlib 5.6, *)
55435543
init?<T: CodingKey>(codingKey: T)
55445544
}
55455545

5546-
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
5547-
extension RawRepresentable where Self: CodingKeyRepresentable, RawValue == String {
5548-
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
5546+
@available(SwiftStdlib 5.6, *)
5547+
extension RawRepresentable
5548+
where Self: CodingKeyRepresentable, RawValue == String {
5549+
@available(SwiftStdlib 5.6, *)
55495550
public var codingKey: CodingKey {
55505551
_DictionaryCodingKey(stringValue: rawValue)
55515552
}
5552-
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
5553+
@available(SwiftStdlib 5.6, *)
55535554
public init?<T: CodingKey>(codingKey: T) {
55545555
self.init(rawValue: codingKey.stringValue)
55555556
}
55565557
}
55575558

5558-
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
5559+
@available(SwiftStdlib 5.6, *)
55595560
extension RawRepresentable where Self: CodingKeyRepresentable, RawValue == Int {
5560-
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
5561+
@available(SwiftStdlib 5.6, *)
55615562
public var codingKey: CodingKey {
55625563
_DictionaryCodingKey(intValue: rawValue)
55635564
}
5564-
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
5565+
@available(SwiftStdlib 5.6, *)
55655566
public init?<T: CodingKey>(codingKey: T) {
55665567
if let intValue = codingKey.intValue {
55675568
self.init(rawValue: intValue)
@@ -5571,13 +5572,13 @@ extension RawRepresentable where Self: CodingKeyRepresentable, RawValue == Int {
55715572
}
55725573
}
55735574

5574-
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
5575+
@available(SwiftStdlib 5.6, *)
55755576
extension Int: CodingKeyRepresentable {
5576-
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
5577+
@available(SwiftStdlib 5.6, *)
55775578
public var codingKey: CodingKey {
55785579
_DictionaryCodingKey(intValue: self)
55795580
}
5580-
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
5581+
@available(SwiftStdlib 5.6, *)
55815582
public init?<T: CodingKey>(codingKey: T) {
55825583
if let intValue = codingKey.intValue {
55835584
self = intValue
@@ -5587,13 +5588,13 @@ extension Int: CodingKeyRepresentable {
55875588
}
55885589
}
55895590

5590-
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
5591+
@available(SwiftStdlib 5.6, *)
55915592
extension String: CodingKeyRepresentable {
5592-
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
5593+
@available(SwiftStdlib 5.6, *)
55935594
public var codingKey: CodingKey {
55945595
_DictionaryCodingKey(stringValue: self)
55955596
}
5596-
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
5597+
@available(SwiftStdlib 5.6, *)
55975598
public init?<T: CodingKey>(codingKey: T) {
55985599
self = codingKey.stringValue
55995600
}
@@ -5603,9 +5604,9 @@ extension Dictionary: Encodable where Key: Encodable, Value: Encodable {
56035604
/// Encodes the contents of this dictionary into the given encoder.
56045605
///
56055606
/// If the dictionary uses keys that are `String`, `Int`, or a type conforming
5606-
/// to `CodingKeyRepresentable`, the contents are encoded in a keyed container.
5607-
/// Otherwise, the contents are encoded as alternating key-value pairs in an
5608-
/// unkeyed container.
5607+
/// to `CodingKeyRepresentable`, the contents are encoded in a keyed
5608+
/// container. Otherwise, the contents are encoded as alternating key-value
5609+
/// pairs in an unkeyed container.
56095610
///
56105611
/// This function throws an error if any values are invalid for the given
56115612
/// encoder's format.
@@ -5626,7 +5627,7 @@ extension Dictionary: Encodable where Key: Encodable, Value: Encodable {
56265627
let codingKey = _DictionaryCodingKey(intValue: key as! Int)
56275628
try container.encode(value, forKey: codingKey)
56285629
}
5629-
} else if #available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *),
5630+
} else if #available(SwiftStdlib 5.6, *),
56305631
Key.self is CodingKeyRepresentable.Type {
56315632
// Since the keys are CodingKeyRepresentable, we can use the `codingKey`
56325633
// to create `_DictionaryCodingKey` instances.
@@ -5690,7 +5691,7 @@ extension Dictionary: Decodable where Key: Decodable, Value: Decodable {
56905691
let value = try container.decode(Value.self, forKey: key)
56915692
self[key.intValue! as! Key] = value
56925693
}
5693-
} else if #available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *),
5694+
} else if #available(SwiftStdlib 5.6, *),
56945695
let keyType = Key.self as? CodingKeyRepresentable.Type {
56955696
// The keys are CodingKeyRepresentable, so we should be able to expect
56965697
// a keyed container.

test/stdlib/CodableTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ class TestCodable : TestCodableSuper {
480480
}
481481
}
482482

483-
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
483+
@available(SwiftStdlib 5.6, *)
484484
func test_Dictionary_JSON() {
485485
enum X: String, Codable { case a, b }
486486
enum Y: String, Codable, CodingKeyRepresentable { case a, b }
@@ -1054,7 +1054,7 @@ if #available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *) {
10541054
tests["test_URLComponents_Plist"] = TestCodable.test_URLComponents_Plist
10551055
}
10561056

1057-
if #available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) {
1057+
if #available(SwiftStdlib 5.6, *) {
10581058
tests["test_Dictionary_JSON"] = TestCodable.test_Dictionary_JSON
10591059
}
10601060

test/stdlib/RawRepresentable-tricky-hashing.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ suite.test("hashValue forwarding") {
107107
//
108108
// See https://github.com/apple/swift/pull/39155
109109

110-
if #available(macOS 9999, iOS 9999, tvOS 9999, watchOS 9999, *) {
110+
if #available(SwiftStdlib 5.6, *) {
111111
let r = CustomRawRepresentable2(rawValue: Bogus())!
112112
expectEqual(r.hashValue, 23.hashValue)
113113
}

validation-test/stdlib/Unicode.swift.gyb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ UnicodeScalarTests.test("init") {
212212
expectEqual(nil, UnicodeScalar(UInt32(0xD800)))
213213
expectEqual("j", Unicode.Scalar(Int(0x6A)))
214214

215-
if #available(macOS 9999, iOS 9999, tvOS 9999, watchOS 9999, *) {
215+
if #available(SwiftStdlib 5.6, *) {
216216
expectEqual(nil, Unicode.Scalar(-0x6A))
217217
}
218218
}

0 commit comments

Comments
 (0)