Skip to content

Commit dd01269

Browse files
Add KeyValuePairs typealias as prep for 5.0 rename (#17711)
1 parent 23f70f7 commit dd01269

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

stdlib/public/core/Mirror.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,12 @@ public struct DictionaryLiteral<Key, Value> : ExpressibleByDictionaryLiteral {
720720
internal let _elements: [(Key, Value)]
721721
}
722722

723+
// NOTE: This will become the new name in Swift 5.0. This typealias is being
724+
// introduced in 4.2 in order to allow code to be migrated to the new name
725+
// using the old compiler, enabling warning-free compilation with both the
726+
// old and new compiler. This is a swift-4.2-branch only change.
727+
public typealias KeyValuePairs<Key,Value> = DictionaryLiteral<Key,Value>
728+
723729
/// `Collection` conformance that allows `DictionaryLiteral` to
724730
/// interoperate with the rest of the standard library.
725731
extension DictionaryLiteral : RandomAccessCollection {

test/stdlib/DictionaryLiteral.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,7 @@ expectType(DictionaryLiteral<String, NSString>.self, &stringNSStringLet)
5151

5252
var hetero: DictionaryLiteral = ["a": 1 as NSNumber, "b": "Foo" as NSString]
5353
expectType(DictionaryLiteral<String, NSObject>.self, &hetero)
54+
55+
let aliased: KeyValuePairs<String,String> = strings
56+
expectType(DictionaryLiteral<String, String>.self, &strings)
57+

0 commit comments

Comments
 (0)