|
10 | 10 | //
|
11 | 11 | //===----------------------------------------------------------------------===//
|
12 | 12 |
|
| 13 | +#if !$Embedded |
| 14 | + |
13 | 15 | /// A unique identifier for a class instance or metatype.
|
14 | 16 | ///
|
15 | 17 | /// This unique identifier is only valid for comparisons during the lifetime
|
@@ -50,33 +52,40 @@ public struct ObjectIdentifier: Sendable {
|
50 | 52 | /// // Prints "false"
|
51 | 53 | ///
|
52 | 54 | /// - Parameter x: An instance of a class.
|
53 |
| -#if $Embedded |
54 |
| - @inlinable // trivial-implementation |
55 |
| - public init<Object: AnyObject>(_ x: Object) { |
56 |
| - self._value = Builtin.bridgeToRawPointer(x) |
57 |
| - } |
58 |
| -#else |
59 | 55 | @inlinable // trivial-implementation
|
60 | 56 | public init(_ x: AnyObject) {
|
61 | 57 | self._value = Builtin.bridgeToRawPointer(x)
|
62 | 58 | }
|
63 |
| -#endif |
| 59 | + |
64 | 60 | /// Creates an instance that uniquely identifies the given metatype.
|
65 | 61 | ///
|
66 | 62 | /// - Parameter: A metatype.
|
67 |
| -#if $Embedded |
68 | 63 | @inlinable // trivial-implementation
|
69 |
| - public init<Object>(_ x: Object.Type) { |
| 64 | + public init(_ x: Any.Type) { |
70 | 65 | self._value = unsafeBitCast(x, to: Builtin.RawPointer.self)
|
71 | 66 | }
|
| 67 | +} |
| 68 | + |
72 | 69 | #else
|
| 70 | + |
| 71 | +@frozen // trivial-implementation |
| 72 | +public struct ObjectIdentifier: Sendable { |
| 73 | + @usableFromInline // trivial-implementation |
| 74 | + internal let _value: Builtin.RawPointer |
| 75 | + |
73 | 76 | @inlinable // trivial-implementation
|
74 |
| - public init(_ x: Any.Type) { |
| 77 | + public init<Object: AnyObject>(_ x: Object) { |
| 78 | + self._value = Builtin.bridgeToRawPointer(x) |
| 79 | + } |
| 80 | + |
| 81 | + @inlinable // trivial-implementation |
| 82 | + public init<Object>(_ x: Object.Type) { |
75 | 83 | self._value = unsafeBitCast(x, to: Builtin.RawPointer.self)
|
76 | 84 | }
|
77 |
| -#endif |
78 | 85 | }
|
79 | 86 |
|
| 87 | +#endif |
| 88 | + |
80 | 89 | @_unavailableInEmbedded
|
81 | 90 | extension ObjectIdentifier: CustomDebugStringConvertible {
|
82 | 91 | /// A textual representation of the identifier, suitable for debugging.
|
|
0 commit comments