Skip to content

Commit 317451c

Browse files
committed
[Runtime][Stdlib][Overlays] Add comments to all the renamed classes explaining the rename and noting that the old name cannot be used due to conflicts.
rdar://problem/35768222
1 parent 798edb9 commit 317451c

13 files changed

+63
-3
lines changed

stdlib/public/SDK/Foundation/Data.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -966,6 +966,9 @@ internal final class _DataStorage {
966966
}
967967
}
968968

969+
// NOTE: older runtimes called this _NSSwiftData. The two must
970+
// coexist, so it was renamed. The old name must not be used in the new
971+
// runtime.
969972
internal class __NSSwiftData : NSData {
970973
var _backing: _DataStorage!
971974
var _range: Range<Data.Index>!

stdlib/public/SDK/Foundation/NSObject.swift

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,15 @@ fileprivate extension NSObject {
4545

4646
}
4747

48+
// NOTE: older overlays called this _KVOKeyPathBridgeMachinery. The two
49+
// must coexist, so it was renamed. The old name must not be used in the
50+
// new runtime.
4851
@objc private class __KVOKeyPathBridgeMachinery : NSObject {
4952
@nonobjc static var keyPathTable: [String : AnyKeyPath] = {
5053
/*
5154
Move all our methods into place. We want the following:
5255
__KVOKeyPathBridgeMachinery's automaticallyNotifiesObserversForKey:, and keyPathsForValuesAffectingValueForKey: methods replaces NSObject's versions of them
53-
NSObject's automaticallyNotifiesObserversForKey:, and keyPathsForValuesAffectingValueForKey: methods replace NSObject's _old_unswizzled_* methods
56+
NSObject's automaticallyNotifiesObserversForKey:, and keyPathsForValuesAffectingValueForKey: methods replace NSObject's __old_unswizzled_* methods
5457
NSObject's _old_unswizzled_* methods replace __KVOKeyPathBridgeMachinery's methods, and are never invoked
5558
*/
5659
let rootClass: AnyClass = NSObject.self
@@ -64,7 +67,7 @@ fileprivate extension NSObject {
6467
let originalDependentImpl = class_getClassMethod(bridgeClass, dependentSel)! //we swizzled it onto this class, so this is actually NSObject's old implementation
6568
let originalDependentSel = #selector(NSObject.__old_unswizzled_keyPathsForValuesAffectingValue(forKey:))
6669
let dummyDependentImpl = class_getClassMethod(rootClass, originalDependentSel)!
67-
method_exchangeImplementations(originalDependentImpl, dummyDependentImpl) // NSObject's original version <-> NSObject's _old_unswizzled_ version
70+
method_exchangeImplementations(originalDependentImpl, dummyDependentImpl) // NSObject's original version <-> NSObject's __old_unswizzled_ version
6871

6972
let autoSel = #selector(NSObject.automaticallyNotifiesObservers(forKey:))
7073
let rootAutoImpl = class_getClassMethod(rootClass, autoSel)!
@@ -74,7 +77,7 @@ fileprivate extension NSObject {
7477
let originalAutoImpl = class_getClassMethod(bridgeClass, autoSel)! //we swizzled it onto this class, so this is actually NSObject's old implementation
7578
let originalAutoSel = #selector(NSObject.__old_unswizzled_automaticallyNotifiesObservers(forKey:))
7679
let dummyAutoImpl = class_getClassMethod(rootClass, originalAutoSel)!
77-
method_exchangeImplementations(originalAutoImpl, dummyAutoImpl) // NSObject's original version <-> NSObject's _old_unswizzled_ version
80+
method_exchangeImplementations(originalAutoImpl, dummyAutoImpl) // NSObject's original version <-> NSObject's __old_unswizzled_ version
7881

7982
return [:]
8083
}()
@@ -128,6 +131,9 @@ func _bridgeStringToKeyPath(_ keyPath:String) -> AnyKeyPath? {
128131
return __KVOKeyPathBridgeMachinery._bridgeKeyPath(keyPath)
129132
}
130133

134+
// NOTE: older overlays called this NSKeyValueObservation. The two must
135+
// coexist, so it was renamed. The old name must not be used in the new
136+
// runtime.
131137
public class _NSKeyValueObservation : NSObject {
132138

133139
@nonobjc weak var object : NSObject?

stdlib/public/SDK/SpriteKit/SpriteKit.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ public typealias SKColor = UIColor
2424
// this class only exists to allow AnyObject lookup of _copyImageData
2525
// since that method only exists in a private header in SpriteKit, the lookup
2626
// mechanism by default fails to accept it as a valid AnyObject call
27+
//
28+
// NOTE: older runtimes called this _SpriteKitMethodProvider. The two must
29+
// coexist, so it was renamed. The old name must not be used in the new
30+
// runtime.
2731
@objc class __SpriteKitMethodProvider : NSObject {
2832
override init() { preconditionFailure("don't touch me") }
2933
@objc func _copyImageData() -> NSData! { return nil }

stdlib/public/core/ContiguousArrayBuffer.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ import SwiftShims
1717
/// initialized. See stdlib/runtime/GlobalObjects.cpp for details.
1818
/// Because it's statically referenced, it requires non-lazy realization
1919
/// by the Objective-C runtime.
20+
///
21+
/// NOTE: older runtimes called this _EmptyArrayStorage. The two must
22+
/// coexist, so it was renamed. The old name must not be used in the new
23+
/// runtime.
2024
@_fixed_layout
2125
@usableFromInline
2226
@_objc_non_lazy_realization

stdlib/public/core/Dictionary.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1804,6 +1804,10 @@ internal protocol _DictionaryBuffer {
18041804
// NOTE: The precise layout of this type is relied on in the runtime
18051805
// to provide a statically allocated empty singleton.
18061806
// See stdlib/public/stubs/GlobalObjects.cpp for details.
1807+
//
1808+
// NOTE: older runtimes called this _RawNativeDictionaryStorage. The two
1809+
// must coexist, so it was renamed. The old name must not be used in the
1810+
// new runtime.
18071811
@_fixed_layout // FIXME(sil-serialize-all)
18081812
@usableFromInline
18091813
@_objc_non_lazy_realization

stdlib/public/core/Runtime.swift.gyb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,10 @@ internal func _rawPointerToString(_ value: Builtin.RawPointer) -> String {
484484
// The @swift_native_objc_runtime_base attribute
485485
// allows us to subclass an Objective-C class and still use the fast Swift
486486
// memory allocator.
487+
//
488+
// NOTE: older runtimes called these _SwiftNativeNSXXX. The two must
489+
// coexist, so they were renamed. The old names must not be used in the
490+
// new runtime.
487491

488492
@_fixed_layout // FIXME(sil-serialize-all)
489493
@usableFromInline // FIXME(sil-serialize-all)

stdlib/public/core/Set.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1407,6 +1407,10 @@ internal protocol _SetBuffer { // FIXME: Remove or refactor for Set.
14071407
// NOTE: The precise layout of this type is relied on in the runtime
14081408
// to provide a statically allocated empty singleton.
14091409
// See stdlib/public/stubs/GlobalObjects.cpp for details.
1410+
//
1411+
// NOTE: older runtimes called this _RawNativeSetStorage. The two must
1412+
// coexist, so it was renamed. The old name must not be used in the new
1413+
// runtime.
14101414
@_fixed_layout // FIXME(sil-serialize-all)
14111415
@usableFromInline
14121416
@_objc_non_lazy_realization

stdlib/public/core/StringBridge.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,10 @@ extension String {
223223
// The @_swift_native_objc_runtime_base attribute
224224
// This allows us to subclass an Objective-C class and use the fast Swift
225225
// memory allocator.
226+
//
227+
// NOTE: older runtimes called this _SwiftNativeNSString. The two must
228+
// coexist, so it was renamed. The old name must not be used in the new
229+
// runtime.
226230
@_fixed_layout // FIXME(sil-serialize-all)
227231
@objc @_swift_native_objc_runtime_base(__SwiftNativeNSStringBase)
228232
public class __SwiftNativeNSString {
@@ -260,6 +264,10 @@ public protocol _NSStringCore : _NSCopying /* _NSFastEnumeration */ {
260264
}
261265

262266
/// An `NSString` built around a slice of contiguous Swift `String` storage.
267+
///
268+
/// NOTE: older runtimes called this _NSContiguousString. The two must
269+
/// coexist, so it was renamed. The old name must not be used in the new
270+
/// runtime.
263271
@_fixed_layout // FIXME(sil-serialize-all)
264272
public final class __NSContiguousString : __SwiftNativeNSString, _NSStringCore {
265273
public let _guts: _StringGuts

stdlib/public/core/SwiftNativeNSArray.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ internal func _isValidArraySubscript(_ index: Int, count: Int) -> Bool {
3737

3838
/// An `NSArray` with Swift-native reference counting and contiguous
3939
/// storage.
40+
///
41+
/// NOTE: older runtimes called this
42+
/// _SwiftNativeNSArrayWithContiguousStorage. The two must coexist, so
43+
/// it was renamed. The old name must not be used in the new runtime.
4044
@_fixed_layout // FIXME(sil-serialize-all)
4145
@usableFromInline
4246
internal class __SwiftNativeNSArrayWithContiguousStorage
@@ -261,6 +265,10 @@ internal class __SwiftNativeNSArrayWithContiguousStorage {
261265
#endif
262266

263267
/// Base class of the heap buffer backing arrays.
268+
///
269+
/// NOTE: older runtimes called this _ContiguousArrayStorageBase. The
270+
/// two must coexist, so it was renamed. The old name must not be used
271+
/// in the new runtime.
264272
@usableFromInline
265273
@_fixed_layout
266274
internal class __ContiguousArrayStorageBase

stdlib/public/runtime/ErrorObject.mm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@
4545
/// A subclass of NSError used to represent bridged native Swift errors.
4646
/// This type cannot be subclassed, and should not ever be instantiated
4747
/// except by the Swift runtime.
48+
///
49+
/// NOTE: older runtimes called this _SwiftNativeNSError. The two must
50+
/// coexist, so it was renamed. The old name must not be used in the new
51+
/// runtime.
4852
@interface __SwiftNativeNSError : NSError
4953
@end
5054

stdlib/public/runtime/SwiftValue.mm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@
4545
// - object header,
4646
// - `SwiftValueHeader` instance,
4747
// - the payload, tail-allocated (the Swift value contained in this box).
48+
//
49+
// NOTE: older runtimes called this _SwiftValue. The two must
50+
// coexist, so it was renamed. The old name must not be used in the new
51+
// runtime.
4852
@interface __SwiftValue : NSObject <NSCopying>
4953

5054
- (id)copyWithZone:(NSZone *)zone;

stdlib/public/stubs/OptionalBridgingHelper.mm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626

2727
/// Class of sentinel objects used to represent the `nil` value of nested
2828
/// optionals.
29+
///
30+
/// NOTE: older runtimes called this _SwiftNull. The two must
31+
/// coexist, so it was renamed. The old name must not be used in the new
32+
/// runtime.
2933
@interface __SwiftNull : NSObject {
3034
@public
3135
unsigned depth;

stdlib/public/stubs/SwiftNativeNSXXXBase.mm.gyb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ extern "C" CFHashCode CFStringHashCString(const uint8_t *bytes, CFIndex len);
4949

5050
using namespace swift;
5151

52+
// NOTE: older runtimes called these _SwiftNativeNSXXXBase. The two must
53+
// coexist, so these were renamed. The old names must not be used in the new
54+
// runtime.
5255
% for Class in ('Array', 'Dictionary', 'Set', 'String', 'Enumerator', 'Data', 'IndexSet'):
5356
SWIFT_RUNTIME_STDLIB_API
5457
@interface __SwiftNativeNS${Class}Base : NS${Class}

0 commit comments

Comments
 (0)