Skip to content

stdlib: Address a couple of ABI FIXMEs by deleting code #7679

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions stdlib/public/core/AnyHashable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -284,12 +284,6 @@ extension AnyHashable : CustomReflectable {
}
}

extension Hashable {
public func _toAnyHashable() -> AnyHashable {
return AnyHashable(self)
}
}

/// Returns a default (non-custom) representation of `self`
/// as `AnyHashable`.
///
Expand Down
2 changes: 1 addition & 1 deletion stdlib/public/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ set(SWIFTLIB_ESSENTIAL
# if we do so, the compiler crashes.
AnyHashable.swift
# END WORKAROUND
HashedCollectionsAnyHashableExtensions.swift.gyb
HashedCollectionsAnyHashableExtensions.swift
Hashing.swift
HeapBuffer.swift
ImplicitlyUnwrappedOptional.swift
Expand Down
9 changes: 1 addition & 8 deletions stdlib/public/core/Hashable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@
//
//===----------------------------------------------------------------------===//

// FIXME(ABI)#33 (Generic subscripts): This protocol exists to identify
// hashable types. It is used for defining an imitation of a generic
// subscript on `Dictionary<AnyHashable, *>`.
public protocol _Hashable {
func _toAnyHashable() -> AnyHashable
}

/// A type that provides an integer hash value.
///
/// You can use any type that conforms to the `Hashable` protocol in a set or
Expand Down Expand Up @@ -90,7 +83,7 @@ public protocol _Hashable {
/// print("New tap detected at (\(nextTap.x), \(nextTap.y)).")
/// }
/// // Prints "New tap detected at (0, 1).")
public protocol Hashable : _Hashable, Equatable {
public protocol Hashable : Equatable {
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,35 +41,3 @@ extension Set where Element == AnyHashable {
.map { $0.base as! ConcreteElement }
}
}

//===----------------------------------------------------------------------===//
// Convenience APIs for Dictionary<AnyHashable, *>
//===----------------------------------------------------------------------===//

extension Dictionary where Key == AnyHashable {
public subscript(_ key: _Hashable) -> Value? {
// FIXME(ABI)#40 (Generic subscripts): replace this API with a
// generic subscript.
get {
return self[key._toAnyHashable()]
}
set {
self[key._toAnyHashable()] = newValue
}
}

@discardableResult
public mutating func updateValue<ConcreteKey : Hashable>(
_ value: Value, forKey key: ConcreteKey
) -> Value? {
return updateValue(value, forKey: AnyHashable(key))
}

@discardableResult
public mutating func removeValue<ConcreteKey : Hashable>(
forKey key: ConcreteKey
) -> Value? {
return removeValue(forKey: AnyHashable(key))
}
}

1 change: 0 additions & 1 deletion test/SILGen/objc_bridging_any.swift
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,5 @@ class AnyHashableClass : NSObject {

// CHECK-LABEL: sil_witness_table shared [fragile] GenericOption: Hashable module objc_generics {
// CHECK-NEXT: base_protocol Equatable: GenericOption: Equatable module objc_generics
// CHECK-NEXT: base_protocol _Hashable: GenericOption: _Hashable module objc_generics
// CHECK-NEXT: method #Hashable.hashValue!getter.1: {{.*}} : @_TTWVSC13GenericOptions8Hashable13objc_genericsFS0_g9hashValueSi
// CHECK-NEXT: }
4 changes: 4 additions & 0 deletions test/api-digester/source-stability.swift.expected
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ Func Array.append(contentsOf:) has been removed
Func ArraySlice.append(contentsOf:) has been removed
Func ContiguousArray.append(contentsOf:) has been removed

/* Unnecessary overload -- no functional change */
Func Dictionary.removeValue(forKey:) has been removed
Func Dictionary.updateValue(_:forKey:) has been removed

/* FIXME: Bogus */
Var Dictionary.endIndex has declared type change from DictionaryIndex<Key, Value> to Dictionary<Key, Value>.Index
Var Dictionary.startIndex has declared type change from DictionaryIndex<Key, Value> to Dictionary<Key, Value>.Index
Expand Down