Skip to content

Commit

Permalink
Fix a merge conflict on main-next. (#627)
Browse files Browse the repository at this point in the history
This PR fixes a conflict between #610 and #619. #610 added a string
cache to `TypeInfo` using `ObjectIdentifier` instances as keys. #619
added support for move-only types to `TypeInfo`. Due to
rdar://134276458, move-only types cannot be used with
`ObjectIdentifier`. This PR uses `UInt` instead until that issue can be
resolved in a future stdlib update.

### Checklist:

- [x] Code and documentation should follow the style of the [Style
Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md).
- [x] If public symbols are renamed or modified, DocC references should
be updated.
  • Loading branch information
grynspan authored Aug 21, 2024
1 parent bba4bdf commit 61d4df9
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions Sources/Testing/Parameterization/TypeInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -312,9 +312,7 @@ extension TypeInfo: Hashable {
public static func ==(lhs: Self, rhs: Self) -> Bool {
switch (lhs._kind, rhs._kind) {
case let (.type(lhs), .type(rhs)):
// == and ObjectIdentifier do not support move-only metatypes, so compare
// the bits of the types directly. SEE: rdar://134276458
return unsafeBitCast(lhs, to: UnsafeRawPointer.self) == unsafeBitCast(rhs, to: UnsafeRawPointer.self)
return ObjectIdentifier(lhs) == ObjectIdentifier(rhs)
default:
return lhs.fullyQualifiedNameComponents == rhs.fullyQualifiedNameComponents
}
Expand All @@ -325,6 +323,21 @@ extension TypeInfo: Hashable {
}
}

// MARK: - ObjectIdentifier support

extension ObjectIdentifier {
/// Initialize an instance of this type from a type reference.
///
/// - Parameters:
/// - type: The type to initialize this instance from.
///
/// - Bug: The standard library should support this conversion.
/// ([134276458](rdar://134276458), [134415960](rdar://134415960))
fileprivate init(_ type: any ~Copyable.Type) {
self.init(unsafeBitCast(type, to: Any.Type.self))
}
}

// MARK: - Codable

extension TypeInfo: Codable {
Expand Down

0 comments on commit 61d4df9

Please sign in to comment.