10
10
//
11
11
//===----------------------------------------------------------------------===//
12
12
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
-
23
13
//===----------------------------------------------------------------------===//
24
14
// Convenience APIs for Set<AnyHashable>
25
15
//===----------------------------------------------------------------------===//
@@ -49,8 +39,7 @@ extension Set {
49
39
}
50
40
}
51
41
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 {
54
43
public mutating func insert<ConcreteElement : Hashable>(
55
44
_ newMember: ConcreteElement
56
45
) -> (inserted: Bool, memberAfterInsert: ConcreteElement) {
@@ -65,15 +54,15 @@ extension Set where Element : _AnyHashableProtocol {
65
54
public mutating func update<ConcreteElement : Hashable>(
66
55
with newMember: ConcreteElement
67
56
) -> ConcreteElement? {
68
- return _concreteElement_update(with: AnyHashable(newMember) as! Element )
57
+ return _concreteElement_update(with: AnyHashable(newMember))
69
58
.map { $0.base as! ConcreteElement }
70
59
}
71
60
72
61
@discardableResult
73
62
public mutating func remove<ConcreteElement : Hashable>(
74
63
_ member: ConcreteElement
75
64
) -> ConcreteElement? {
76
- return _concreteElement_remove(AnyHashable(member) as! Element )
65
+ return _concreteElement_remove(AnyHashable(member))
77
66
.map { $0.base as! ConcreteElement }
78
67
}
79
68
}
@@ -109,31 +98,30 @@ extension Dictionary {
109
98
}
110
99
}
111
100
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 {
114
102
public subscript(_ key: _Hashable) -> Value? {
115
103
// FIXME(ABI)#40 (Generic subscripts): replace this API with a
116
104
// generic subscript.
117
105
get {
118
- return self[_concreteKey: key._toAnyHashable() as! Key ]
106
+ return self[_concreteKey: key._toAnyHashable()]
119
107
}
120
108
set {
121
- self[_concreteKey: key._toAnyHashable() as! Key ] = newValue
109
+ self[_concreteKey: key._toAnyHashable()] = newValue
122
110
}
123
111
}
124
112
125
113
@discardableResult
126
114
public mutating func updateValue<ConcreteKey : Hashable>(
127
115
_ value: Value, forKey key: ConcreteKey
128
116
) -> Value? {
129
- return _concreteKey_updateValue(value, forKey: AnyHashable(key) as! Key )
117
+ return _concreteKey_updateValue(value, forKey: AnyHashable(key))
130
118
}
131
119
132
120
@discardableResult
133
121
public mutating func removeValue<ConcreteKey : Hashable>(
134
122
forKey key: ConcreteKey
135
123
) -> Value? {
136
- return _concreteKey_removeValue(forKey: AnyHashable(key) as! Key )
124
+ return _concreteKey_removeValue(forKey: AnyHashable(key))
137
125
}
138
126
}
139
127
0 commit comments