Skip to content

Commit 61d4df9

Browse files
authored
Fix a merge conflict on main-next. (#627)
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.
1 parent bba4bdf commit 61d4df9

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

Sources/Testing/Parameterization/TypeInfo.swift

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,9 +312,7 @@ extension TypeInfo: Hashable {
312312
public static func ==(lhs: Self, rhs: Self) -> Bool {
313313
switch (lhs._kind, rhs._kind) {
314314
case let (.type(lhs), .type(rhs)):
315-
// == and ObjectIdentifier do not support move-only metatypes, so compare
316-
// the bits of the types directly. SEE: rdar://134276458
317-
return unsafeBitCast(lhs, to: UnsafeRawPointer.self) == unsafeBitCast(rhs, to: UnsafeRawPointer.self)
315+
return ObjectIdentifier(lhs) == ObjectIdentifier(rhs)
318316
default:
319317
return lhs.fullyQualifiedNameComponents == rhs.fullyQualifiedNameComponents
320318
}
@@ -325,6 +323,21 @@ extension TypeInfo: Hashable {
325323
}
326324
}
327325

326+
// MARK: - ObjectIdentifier support
327+
328+
extension ObjectIdentifier {
329+
/// Initialize an instance of this type from a type reference.
330+
///
331+
/// - Parameters:
332+
/// - type: The type to initialize this instance from.
333+
///
334+
/// - Bug: The standard library should support this conversion.
335+
/// ([134276458](rdar://134276458), [134415960](rdar://134415960))
336+
fileprivate init(_ type: any ~Copyable.Type) {
337+
self.init(unsafeBitCast(type, to: Any.Type.self))
338+
}
339+
}
340+
328341
// MARK: - Codable
329342

330343
extension TypeInfo: Codable {

0 commit comments

Comments
 (0)