Skip to content

Commit 1686800

Browse files
authored
Merge pull request swiftlang#69180 from kubamracek/embedded-move-protocol-aliases
[embedded] Move _CustomStringConvertibleOrNone/_LosslessStringConvertibleOrNone to avoid detaching doccomments from their declarations
2 parents 681a2b7 + 043a9fd commit 1686800

File tree

2 files changed

+32
-25
lines changed

2 files changed

+32
-25
lines changed

stdlib/public/core/Integers.swift

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,12 @@ extension AdditiveArithmetic {
406406
}
407407
}
408408

409+
#if !$Embedded
410+
public typealias _CustomStringConvertibleOrNone = CustomStringConvertible
411+
#else
412+
public typealias _CustomStringConvertibleOrNone = Any
413+
#endif
414+
409415
//===----------------------------------------------------------------------===//
410416
//===--- BinaryInteger ----------------------------------------------------===//
411417
//===----------------------------------------------------------------------===//
@@ -566,13 +572,6 @@ extension AdditiveArithmetic {
566572
/// print("\(z) is greater than \(x).")
567573
/// }
568574
/// // Prints "23 is greater than -23."
569-
570-
#if !$Embedded
571-
public typealias _CustomStringConvertibleOrNone = CustomStringConvertible
572-
#else
573-
public typealias _CustomStringConvertibleOrNone = Any
574-
#endif
575-
576575
public protocol BinaryInteger :
577576
Hashable, Numeric, _CustomStringConvertibleOrNone, Strideable
578577
where Magnitude: BinaryInteger, Magnitude.Magnitude == Magnitude
@@ -1831,6 +1830,12 @@ extension BinaryInteger {
18311830
}
18321831
}
18331832

1833+
#if !$Embedded
1834+
public typealias _LosslessStringConvertibleOrNone = LosslessStringConvertible
1835+
#else
1836+
public protocol _LosslessStringConvertibleOrNone {}
1837+
#endif
1838+
18341839
//===----------------------------------------------------------------------===//
18351840
//===--- FixedWidthInteger ------------------------------------------------===//
18361841
//===----------------------------------------------------------------------===//
@@ -1899,13 +1904,6 @@ extension BinaryInteger {
18991904
/// customization points for arithmetic operations. When you provide just those
19001905
/// methods, the standard library provides default implementations for all
19011906
/// other arithmetic methods and operators.
1902-
1903-
#if !$Embedded
1904-
public typealias _LosslessStringConvertibleOrNone = LosslessStringConvertible
1905-
#else
1906-
public protocol _LosslessStringConvertibleOrNone {}
1907-
#endif
1908-
19091907
public protocol FixedWidthInteger: BinaryInteger, _LosslessStringConvertibleOrNone
19101908
where Magnitude: FixedWidthInteger & UnsignedInteger,
19111909
Stride: FixedWidthInteger & SignedInteger {

stdlib/public/core/ObjectIdentifier.swift

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
#if !$Embedded
14+
1315
/// A unique identifier for a class instance or metatype.
1416
///
1517
/// This unique identifier is only valid for comparisons during the lifetime
@@ -50,33 +52,40 @@ public struct ObjectIdentifier: Sendable {
5052
/// // Prints "false"
5153
///
5254
/// - 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
5955
@inlinable // trivial-implementation
6056
public init(_ x: AnyObject) {
6157
self._value = Builtin.bridgeToRawPointer(x)
6258
}
63-
#endif
59+
6460
/// Creates an instance that uniquely identifies the given metatype.
6561
///
6662
/// - Parameter: A metatype.
67-
#if $Embedded
6863
@inlinable // trivial-implementation
69-
public init<Object>(_ x: Object.Type) {
64+
public init(_ x: Any.Type) {
7065
self._value = unsafeBitCast(x, to: Builtin.RawPointer.self)
7166
}
67+
}
68+
7269
#else
70+
71+
@frozen // trivial-implementation
72+
public struct ObjectIdentifier: Sendable {
73+
@usableFromInline // trivial-implementation
74+
internal let _value: Builtin.RawPointer
75+
7376
@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) {
7583
self._value = unsafeBitCast(x, to: Builtin.RawPointer.self)
7684
}
77-
#endif
7885
}
7986

87+
#endif
88+
8089
@_unavailableInEmbedded
8190
extension ObjectIdentifier: CustomDebugStringConvertible {
8291
/// A textual representation of the identifier, suitable for debugging.

0 commit comments

Comments
 (0)