Skip to content

Commit c080be7

Browse files
authored
Merge pull request swiftlang#7679 from slavapestov/any-hashable-stdlib-cleanup
stdlib: Address a couple of ABI FIXMEs by deleting code
2 parents 781820b + 66bcf5b commit c080be7

File tree

6 files changed

+6
-48
lines changed

6 files changed

+6
-48
lines changed

stdlib/public/core/AnyHashable.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -284,12 +284,6 @@ extension AnyHashable : CustomReflectable {
284284
}
285285
}
286286

287-
extension Hashable {
288-
public func _toAnyHashable() -> AnyHashable {
289-
return AnyHashable(self)
290-
}
291-
}
292-
293287
/// Returns a default (non-custom) representation of `self`
294288
/// as `AnyHashable`.
295289
///

stdlib/public/core/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ set(SWIFTLIB_ESSENTIAL
6363
# if we do so, the compiler crashes.
6464
AnyHashable.swift
6565
# END WORKAROUND
66-
HashedCollectionsAnyHashableExtensions.swift.gyb
66+
HashedCollectionsAnyHashableExtensions.swift
6767
Hashing.swift
6868
HeapBuffer.swift
6969
ImplicitlyUnwrappedOptional.swift

stdlib/public/core/Hashable.swift

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,6 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
// FIXME(ABI)#33 (Generic subscripts): This protocol exists to identify
14-
// hashable types. It is used for defining an imitation of a generic
15-
// subscript on `Dictionary<AnyHashable, *>`.
16-
public protocol _Hashable {
17-
func _toAnyHashable() -> AnyHashable
18-
}
19-
2013
/// A type that provides an integer hash value.
2114
///
2215
/// You can use any type that conforms to the `Hashable` protocol in a set or
@@ -90,7 +83,7 @@ public protocol _Hashable {
9083
/// print("New tap detected at (\(nextTap.x), \(nextTap.y)).")
9184
/// }
9285
/// // Prints "New tap detected at (0, 1).")
93-
public protocol Hashable : _Hashable, Equatable {
86+
public protocol Hashable : Equatable {
9487
/// The hash value.
9588
///
9689
/// Hash values are not guaranteed to be equal across different executions of

stdlib/public/core/HashedCollectionsAnyHashableExtensions.swift.gyb renamed to stdlib/public/core/HashedCollectionsAnyHashableExtensions.swift

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -41,35 +41,3 @@ extension Set where Element == AnyHashable {
4141
.map { $0.base as! ConcreteElement }
4242
}
4343
}
44-
45-
//===----------------------------------------------------------------------===//
46-
// Convenience APIs for Dictionary<AnyHashable, *>
47-
//===----------------------------------------------------------------------===//
48-
49-
extension Dictionary where Key == AnyHashable {
50-
public subscript(_ key: _Hashable) -> Value? {
51-
// FIXME(ABI)#40 (Generic subscripts): replace this API with a
52-
// generic subscript.
53-
get {
54-
return self[key._toAnyHashable()]
55-
}
56-
set {
57-
self[key._toAnyHashable()] = newValue
58-
}
59-
}
60-
61-
@discardableResult
62-
public mutating func updateValue<ConcreteKey : Hashable>(
63-
_ value: Value, forKey key: ConcreteKey
64-
) -> Value? {
65-
return updateValue(value, forKey: AnyHashable(key))
66-
}
67-
68-
@discardableResult
69-
public mutating func removeValue<ConcreteKey : Hashable>(
70-
forKey key: ConcreteKey
71-
) -> Value? {
72-
return removeValue(forKey: AnyHashable(key))
73-
}
74-
}
75-

test/SILGen/objc_bridging_any.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,5 @@ class AnyHashableClass : NSObject {
726726

727727
// CHECK-LABEL: sil_witness_table shared [fragile] GenericOption: Hashable module objc_generics {
728728
// CHECK-NEXT: base_protocol Equatable: GenericOption: Equatable module objc_generics
729-
// CHECK-NEXT: base_protocol _Hashable: GenericOption: _Hashable module objc_generics
730729
// CHECK-NEXT: method #Hashable.hashValue!getter.1: {{.*}} : @_TTWVSC13GenericOptions8Hashable13objc_genericsFS0_g9hashValueSi
731730
// CHECK-NEXT: }

test/api-digester/source-stability.swift.expected

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ Func Array.append(contentsOf:) has been removed
1717
Func ArraySlice.append(contentsOf:) has been removed
1818
Func ContiguousArray.append(contentsOf:) has been removed
1919

20+
/* Unnecessary overload -- no functional change */
21+
Func Dictionary.removeValue(forKey:) has been removed
22+
Func Dictionary.updateValue(_:forKey:) has been removed
23+
2024
/* FIXME: Bogus */
2125
Var Dictionary.endIndex has declared type change from DictionaryIndex<Key, Value> to Dictionary<Key, Value>.Index
2226
Var Dictionary.startIndex has declared type change from DictionaryIndex<Key, Value> to Dictionary<Key, Value>.Index

0 commit comments

Comments
 (0)