1010//
1111//===----------------------------------------------------------------------===//
1212
13- // FIXME(ABI)#35 (Concrete Same Type Requirements): This protocol exists to identify
14- // `AnyHashable` in conditional extensions. Replace this protocol
15- // with conditional extensions on `Set` and `Dictionary` "where Key ==
16- // AnyHashable".
17- public protocol _AnyHashableProtocol {
18- var base: Any { get }
19- }
20-
21- extension AnyHashable : _AnyHashableProtocol {}
22-
2313//===----------------------------------------------------------------------===//
2414// Convenience APIs for Set<AnyHashable>
2515//===----------------------------------------------------------------------===//
@@ -49,8 +39,7 @@ extension Set {
4939 }
5040}
5141
52- // FIXME(ABI)#37 (Concrete Same Type Requirements): replace with `where Element == AnyHashable`.
53- extension Set where Element : _AnyHashableProtocol {
42+ extension Set where Element == AnyHashable {
5443 public mutating func insert<ConcreteElement : Hashable>(
5544 _ newMember: ConcreteElement
5645 ) -> (inserted: Bool, memberAfterInsert: ConcreteElement) {
@@ -65,15 +54,15 @@ extension Set where Element : _AnyHashableProtocol {
6554 public mutating func update<ConcreteElement : Hashable>(
6655 with newMember: ConcreteElement
6756 ) -> ConcreteElement? {
68- return _concreteElement_update(with: AnyHashable(newMember) as! Element )
57+ return _concreteElement_update(with: AnyHashable(newMember))
6958 .map { $0.base as! ConcreteElement }
7059 }
7160
7261 @discardableResult
7362 public mutating func remove<ConcreteElement : Hashable>(
7463 _ member: ConcreteElement
7564 ) -> ConcreteElement? {
76- return _concreteElement_remove(AnyHashable(member) as! Element )
65+ return _concreteElement_remove(AnyHashable(member))
7766 .map { $0.base as! ConcreteElement }
7867 }
7968}
@@ -109,31 +98,30 @@ extension Dictionary {
10998 }
11099}
111100
112- // FIXME(ABI)#39 (Concrete Same Type Requirements): replace with `where Element == AnyHashable`.
113- extension Dictionary where Key : _AnyHashableProtocol {
101+ extension Dictionary where Key == AnyHashable {
114102 public subscript(_ key: _Hashable) -> Value? {
115103 // FIXME(ABI)#40 (Generic subscripts): replace this API with a
116104 // generic subscript.
117105 get {
118- return self[_concreteKey: key._toAnyHashable() as! Key ]
106+ return self[_concreteKey: key._toAnyHashable()]
119107 }
120108 set {
121- self[_concreteKey: key._toAnyHashable() as! Key ] = newValue
109+ self[_concreteKey: key._toAnyHashable()] = newValue
122110 }
123111 }
124112
125113 @discardableResult
126114 public mutating func updateValue<ConcreteKey : Hashable>(
127115 _ value: Value, forKey key: ConcreteKey
128116 ) -> Value? {
129- return _concreteKey_updateValue(value, forKey: AnyHashable(key) as! Key )
117+ return _concreteKey_updateValue(value, forKey: AnyHashable(key))
130118 }
131119
132120 @discardableResult
133121 public mutating func removeValue<ConcreteKey : Hashable>(
134122 forKey key: ConcreteKey
135123 ) -> Value? {
136- return _concreteKey_removeValue(forKey: AnyHashable(key) as! Key )
124+ return _concreteKey_removeValue(forKey: AnyHashable(key))
137125 }
138126}
139127
0 commit comments