diff --git a/lib/AST/Attr.cpp b/lib/AST/Attr.cpp index 138b5dd5db9a8..848f45654248b 100644 --- a/lib/AST/Attr.cpp +++ b/lib/AST/Attr.cpp @@ -552,10 +552,10 @@ bool DeclAttribute::printImpl(ASTPrinter &Printer, const PrintOptions &Options, } case DAK_ObjCRuntimeName: { - Printer.printAttrName("@objc"); + Printer.printAttrName("@_objcRuntimeName"); Printer << "("; auto *attr = cast(this); - Printer << "\"" << attr->Name << "\""; + Printer << attr->Name; Printer << ")"; break; } diff --git a/stdlib/public/Darwin/AppKit/NSGraphics.swift b/stdlib/public/Darwin/AppKit/NSGraphics.swift index 6cc836c6bcbfc..f4e2a7c77a267 100644 --- a/stdlib/public/Darwin/AppKit/NSGraphics.swift +++ b/stdlib/public/Darwin/AppKit/NSGraphics.swift @@ -181,7 +181,10 @@ extension NSWindow.Depth { } extension NSAnimationEffect { - private class _CompletionHandlerDelegate : NSObject { + // NOTE: older overlays called this class _CompletionHandlerDelegate. + // The two must coexist without a conflicting ObjC class name, so it + // was renamed. The old name must not be used in the new runtime. + private class __CompletionHandlerDelegate : NSObject { var completionHandler: () -> Void = { } @objc func animationEffectDidEnd(_ contextInfo: UnsafeMutableRawPointer?) { completionHandler() @@ -190,7 +193,7 @@ extension NSAnimationEffect { @available(swift 4) public func show(centeredAt centerLocation: NSPoint, size: NSSize, completionHandler: @escaping () -> Void = { }) { - let delegate = _CompletionHandlerDelegate() + let delegate = __CompletionHandlerDelegate() delegate.completionHandler = completionHandler // Note that the delegate of `__NSShowAnimationEffect` is retained for the // duration of the animation. @@ -199,7 +202,7 @@ extension NSAnimationEffect { centerLocation, size, delegate, - #selector(_CompletionHandlerDelegate.animationEffectDidEnd(_:)), + #selector(__CompletionHandlerDelegate.animationEffectDidEnd(_:)), nil) } } diff --git a/stdlib/public/Darwin/Dispatch/Block.swift b/stdlib/public/Darwin/Dispatch/Block.swift index e3558e427718b..1f9d8b100b107 100644 --- a/stdlib/public/Darwin/Dispatch/Block.swift +++ b/stdlib/public/Darwin/Dispatch/Block.swift @@ -34,7 +34,12 @@ public struct DispatchWorkItemFlags : OptionSet, RawRepresentable { public static let enforceQoS = DispatchWorkItemFlags(rawValue: 0x20) } +// NOTE: older overlays had Dispatch.DispatchWorkItem as the ObjC name. +// The two must coexist, so it was renamed. The old name must not be +// used in the new runtime. _TtC8Dispatch17_DispatchWorkItem is the +// mangled name for Dispatch._DispatchWorkItem. @available(macOS 10.10, iOS 8.0, *) +@_objcRuntimeName(_TtC8Dispatch17_DispatchWorkItem) public class DispatchWorkItem { internal var _block: _DispatchBlock diff --git a/stdlib/public/Darwin/Foundation/CharacterSet.swift b/stdlib/public/Darwin/Foundation/CharacterSet.swift index 3161d6a7b9bb4..68df36ea75cf4 100644 --- a/stdlib/public/Darwin/Foundation/CharacterSet.swift +++ b/stdlib/public/Darwin/Foundation/CharacterSet.swift @@ -29,7 +29,10 @@ private func _utfRangeToCFRange(_ inRange : ClosedRange) -> CFRa // MARK: - -fileprivate final class _CharacterSetStorage : Hashable { +// NOTE: older overlays called this class _CharacterSetStorage. +// The two must coexist without a conflicting ObjC class name, so it +// was renamed. The old name must not be used in the new runtime. +fileprivate final class __CharacterSetStorage : Hashable { fileprivate enum Backing { case immutable(CFCharacterSet) case mutable(CFMutableCharacterSet) @@ -58,7 +61,7 @@ fileprivate final class _CharacterSetStorage : Hashable { } } - fileprivate static func ==(lhs : _CharacterSetStorage, rhs : _CharacterSetStorage) -> Bool { + fileprivate static func ==(lhs : __CharacterSetStorage, rhs : __CharacterSetStorage) -> Bool { switch (lhs._backing, rhs._backing) { case (.immutable(let cs1), .immutable(let cs2)): return CFEqual(cs1, cs2) @@ -73,12 +76,12 @@ fileprivate final class _CharacterSetStorage : Hashable { // MARK: - - fileprivate func mutableCopy() -> _CharacterSetStorage { + fileprivate func mutableCopy() -> __CharacterSetStorage { switch _backing { case .immutable(let cs): - return _CharacterSetStorage(mutableReference: CFCharacterSetCreateMutableCopy(nil, cs)) + return __CharacterSetStorage(mutableReference: CFCharacterSetCreateMutableCopy(nil, cs)) case .mutable(let cs): - return _CharacterSetStorage(mutableReference: CFCharacterSetCreateMutableCopy(nil, cs)) + return __CharacterSetStorage(mutableReference: CFCharacterSetCreateMutableCopy(nil, cs)) } } @@ -223,7 +226,7 @@ fileprivate final class _CharacterSetStorage : Hashable { // When the underlying collection does not have a method to return new CharacterSets with changes applied, so we will copy and apply here - private static func _apply(_ lhs : _CharacterSetStorage, _ rhs : _CharacterSetStorage, _ f : (CFMutableCharacterSet, CFCharacterSet) -> ()) -> CharacterSet { + private static func _apply(_ lhs : __CharacterSetStorage, _ rhs : __CharacterSetStorage, _ f : (CFMutableCharacterSet, CFCharacterSet) -> ()) -> CharacterSet { let copyOfMe : CFMutableCharacterSet switch lhs._backing { case .immutable(let cs): @@ -239,10 +242,10 @@ fileprivate final class _CharacterSetStorage : Hashable { f(copyOfMe, cs) } - return CharacterSet(_uncopiedStorage: _CharacterSetStorage(mutableReference: copyOfMe)) + return CharacterSet(_uncopiedStorage: __CharacterSetStorage(mutableReference: copyOfMe)) } - private func _applyMutation(_ other : _CharacterSetStorage, _ f : (CFMutableCharacterSet, CFCharacterSet) -> ()) { + private func _applyMutation(_ other : __CharacterSetStorage, _ f : (CFMutableCharacterSet, CFCharacterSet) -> ()) { switch _backing { case .immutable(let cs): let r = CFCharacterSetCreateMutableCopy(nil, cs)! @@ -267,47 +270,47 @@ fileprivate final class _CharacterSetStorage : Hashable { fileprivate var inverted : CharacterSet { switch _backing { case .immutable(let cs): - return CharacterSet(_uncopiedStorage: _CharacterSetStorage(immutableReference: CFCharacterSetCreateInvertedSet(nil, cs))) + return CharacterSet(_uncopiedStorage: __CharacterSetStorage(immutableReference: CFCharacterSetCreateInvertedSet(nil, cs))) case .mutable(let cs): // Even if input is mutable, the result is immutable - return CharacterSet(_uncopiedStorage: _CharacterSetStorage(immutableReference: CFCharacterSetCreateInvertedSet(nil, cs))) + return CharacterSet(_uncopiedStorage: __CharacterSetStorage(immutableReference: CFCharacterSetCreateInvertedSet(nil, cs))) } } - fileprivate func union(_ other: _CharacterSetStorage) -> CharacterSet { - return _CharacterSetStorage._apply(self, other, CFCharacterSetUnion) + fileprivate func union(_ other: __CharacterSetStorage) -> CharacterSet { + return __CharacterSetStorage._apply(self, other, CFCharacterSetUnion) } - fileprivate func formUnion(_ other: _CharacterSetStorage) { + fileprivate func formUnion(_ other: __CharacterSetStorage) { _applyMutation(other, CFCharacterSetUnion) } - fileprivate func intersection(_ other: _CharacterSetStorage) -> CharacterSet { - return _CharacterSetStorage._apply(self, other, CFCharacterSetIntersect) + fileprivate func intersection(_ other: __CharacterSetStorage) -> CharacterSet { + return __CharacterSetStorage._apply(self, other, CFCharacterSetIntersect) } - fileprivate func formIntersection(_ other: _CharacterSetStorage) { + fileprivate func formIntersection(_ other: __CharacterSetStorage) { _applyMutation(other, CFCharacterSetIntersect) } - fileprivate func subtracting(_ other: _CharacterSetStorage) -> CharacterSet { + fileprivate func subtracting(_ other: __CharacterSetStorage) -> CharacterSet { return intersection(other.inverted._storage) } - fileprivate func subtract(_ other: _CharacterSetStorage) { + fileprivate func subtract(_ other: __CharacterSetStorage) { _applyMutation(other.inverted._storage, CFCharacterSetIntersect) } - fileprivate func symmetricDifference(_ other: _CharacterSetStorage) -> CharacterSet { + fileprivate func symmetricDifference(_ other: __CharacterSetStorage) -> CharacterSet { return union(other).subtracting(intersection(other)) } - fileprivate func formSymmetricDifference(_ other: _CharacterSetStorage) { + fileprivate func formSymmetricDifference(_ other: __CharacterSetStorage) { // This feels like cheating _backing = symmetricDifference(other)._storage._backing } - fileprivate func isSuperset(of other: _CharacterSetStorage) -> Bool { + fileprivate func isSuperset(of other: __CharacterSetStorage) -> Bool { switch _backing { case .immutable(let cs): switch other._backing { @@ -363,35 +366,35 @@ fileprivate final class _CharacterSetStorage : Hashable { public struct CharacterSet : ReferenceConvertible, Equatable, Hashable, SetAlgebra { public typealias ReferenceType = NSCharacterSet - fileprivate var _storage : _CharacterSetStorage + fileprivate var _storage : __CharacterSetStorage // MARK: Init methods /// Initialize an empty instance. public init() { // It's unlikely that we are creating an empty character set with no intention to mutate it - _storage = _CharacterSetStorage(mutableReference: CFCharacterSetCreateMutable(nil)) + _storage = __CharacterSetStorage(mutableReference: CFCharacterSetCreateMutable(nil)) } /// Initialize with a range of integers. /// /// It is the caller's responsibility to ensure that the values represent valid `Unicode.Scalar` values, if that is what is desired. public init(charactersIn range: Range) { - _storage = _CharacterSetStorage(immutableReference: CFCharacterSetCreateWithCharactersInRange(nil, _utfRangeToCFRange(range))) + _storage = __CharacterSetStorage(immutableReference: CFCharacterSetCreateWithCharactersInRange(nil, _utfRangeToCFRange(range))) } /// Initialize with a closed range of integers. /// /// It is the caller's responsibility to ensure that the values represent valid `Unicode.Scalar` values, if that is what is desired. public init(charactersIn range: ClosedRange) { - _storage = _CharacterSetStorage(immutableReference: CFCharacterSetCreateWithCharactersInRange(nil, _utfRangeToCFRange(range))) + _storage = __CharacterSetStorage(immutableReference: CFCharacterSetCreateWithCharactersInRange(nil, _utfRangeToCFRange(range))) } /// Initialize with the characters in the given string. /// /// - parameter string: The string content to inspect for characters. public init(charactersIn string: __shared String) { - _storage = _CharacterSetStorage(immutableReference: CFCharacterSetCreateWithCharactersInString(nil, string as CFString)) + _storage = __CharacterSetStorage(immutableReference: CFCharacterSetCreateWithCharactersInString(nil, string as CFString)) } /// Initialize with a bitmap representation. @@ -399,7 +402,7 @@ public struct CharacterSet : ReferenceConvertible, Equatable, Hashable, SetAlgeb /// This method is useful for creating a character set object with data from a file or other external data source. /// - parameter data: The bitmap representation. public init(bitmapRepresentation data: __shared Data) { - _storage = _CharacterSetStorage(immutableReference: CFCharacterSetCreateWithBitmapRepresentation(nil, data as CFData)) + _storage = __CharacterSetStorage(immutableReference: CFCharacterSetCreateWithBitmapRepresentation(nil, data as CFData)) } /// Initialize with the contents of a file. @@ -409,26 +412,26 @@ public struct CharacterSet : ReferenceConvertible, Equatable, Hashable, SetAlgeb public init?(contentsOfFile file: __shared String) { do { let data = try Data(contentsOf: URL(fileURLWithPath: file), options: .mappedIfSafe) - _storage = _CharacterSetStorage(immutableReference: CFCharacterSetCreateWithBitmapRepresentation(nil, data as CFData)) + _storage = __CharacterSetStorage(immutableReference: CFCharacterSetCreateWithBitmapRepresentation(nil, data as CFData)) } catch { return nil } } fileprivate init(_bridged characterSet: __shared NSCharacterSet) { - _storage = _CharacterSetStorage(immutableReference: characterSet.copy() as! CFCharacterSet) + _storage = __CharacterSetStorage(immutableReference: characterSet.copy() as! CFCharacterSet) } fileprivate init(_uncopiedImmutableReference characterSet: CFCharacterSet) { - _storage = _CharacterSetStorage(immutableReference: characterSet) + _storage = __CharacterSetStorage(immutableReference: characterSet) } - fileprivate init(_uncopiedStorage : _CharacterSetStorage) { + fileprivate init(_uncopiedStorage : __CharacterSetStorage) { _storage = _uncopiedStorage } fileprivate init(_builtIn: __shared CFCharacterSetPredefinedSet) { - _storage = _CharacterSetStorage(immutableReference: CFCharacterSetGetPredefined(_builtIn)) + _storage = __CharacterSetStorage(immutableReference: CFCharacterSetGetPredefined(_builtIn)) } // MARK: Static functions diff --git a/stdlib/public/Darwin/Foundation/Data.swift b/stdlib/public/Darwin/Foundation/Data.swift index 699d334669c9e..725245bcabcab 100644 --- a/stdlib/public/Darwin/Foundation/Data.swift +++ b/stdlib/public/Darwin/Foundation/Data.swift @@ -64,8 +64,11 @@ internal func __NSDataIsCompact(_ data: NSData) -> Bool { // Underlying storage representation for medium and large data. // Inlinability strategy: methods from here should not inline into InlineSlice or LargeSlice unless trivial. +// NOTE: older overlays called this class _DataStorage. The two must +// coexist without a conflicting ObjC class name, so it was renamed. +// The old name must not be used in the new runtime. @usableFromInline -internal final class _DataStorage { +internal final class __DataStorage { @usableFromInline static let maxSize = Int.max >> 1 @usableFromInline static let vmOpsThreshold = NSPageSize() * 4 @@ -83,7 +86,7 @@ internal final class _DataStorage { var dest = dest_ var source = source_ var num = num_ - if _DataStorage.vmOpsThreshold <= num && ((unsafeBitCast(source, to: Int.self) | Int(bitPattern: dest)) & (NSPageSize() - 1)) == 0 { + if __DataStorage.vmOpsThreshold <= num && ((unsafeBitCast(source, to: Int.self) | Int(bitPattern: dest)) & (NSPageSize() - 1)) == 0 { let pages = NSRoundDownToMultipleOfPageSize(num) NSCopyMemoryPages(source!, dest, pages) source = source!.advanced(by: pages) @@ -146,7 +149,7 @@ internal final class _DataStorage { @inlinable // This is inlinable as trivially computable. var isExternallyOwned: Bool { - // all _DataStorages will have some sort of capacity, because empty cases hit the .empty enum _Representation + // all __DataStorages will have some sort of capacity, because empty cases hit the .empty enum _Representation // anything with 0 capacity means that we have not allocated this pointer and concequently mutation is not ours to make. return _capacity == 0 } @@ -158,8 +161,8 @@ internal final class _DataStorage { if newLength == 0 { if isExternallyOwned { let newCapacity = malloc_good_size(_length) - let newBytes = _DataStorage.allocate(newCapacity, false) - _DataStorage.move(newBytes!, _bytes!, _length) + let newBytes = __DataStorage.allocate(newCapacity, false) + __DataStorage.move(newBytes!, _bytes!, _length) _freeBytes() _bytes = newBytes _capacity = newCapacity @@ -167,9 +170,9 @@ internal final class _DataStorage { } } else if isExternallyOwned { let newCapacity = malloc_good_size(newLength) - let newBytes = _DataStorage.allocate(newCapacity, clear) + let newBytes = __DataStorage.allocate(newCapacity, clear) if let bytes = _bytes { - _DataStorage.move(newBytes!, bytes, _length) + __DataStorage.move(newBytes!, bytes, _length) } _freeBytes() _bytes = newBytes @@ -178,27 +181,27 @@ internal final class _DataStorage { _needToZero = true } else { let cap = _capacity - var additionalCapacity = (newLength >> (_DataStorage.vmOpsThreshold <= newLength ? 2 : 1)) + var additionalCapacity = (newLength >> (__DataStorage.vmOpsThreshold <= newLength ? 2 : 1)) if Int.max - additionalCapacity < newLength { additionalCapacity = 0 } var newCapacity = malloc_good_size(Swift.max(cap, newLength + additionalCapacity)) let origLength = _length - var allocateCleared = clear && _DataStorage.shouldAllocateCleared(newCapacity) + var allocateCleared = clear && __DataStorage.shouldAllocateCleared(newCapacity) var newBytes: UnsafeMutableRawPointer? = nil if _bytes == nil { - newBytes = _DataStorage.allocate(newCapacity, allocateCleared) + newBytes = __DataStorage.allocate(newCapacity, allocateCleared) if newBytes == nil { /* Try again with minimum length */ - allocateCleared = clear && _DataStorage.shouldAllocateCleared(newLength) - newBytes = _DataStorage.allocate(newLength, allocateCleared) + allocateCleared = clear && __DataStorage.shouldAllocateCleared(newLength) + newBytes = __DataStorage.allocate(newLength, allocateCleared) } } else { let tryCalloc = (origLength == 0 || (newLength / origLength) >= 4) if allocateCleared && tryCalloc { - newBytes = _DataStorage.allocate(newCapacity, true) + newBytes = __DataStorage.allocate(newCapacity, true) if let newBytes = newBytes { - _DataStorage.move(newBytes, _bytes!, origLength) + __DataStorage.move(newBytes, _bytes!, origLength) _freeBytes() } } @@ -206,9 +209,9 @@ internal final class _DataStorage { if newBytes == nil { allocateCleared = false if _deallocator != nil { - newBytes = _DataStorage.allocate(newCapacity, true) + newBytes = __DataStorage.allocate(newCapacity, true) if let newBytes = newBytes { - _DataStorage.move(newBytes, _bytes!, origLength) + __DataStorage.move(newBytes, _bytes!, origLength) _freeBytes() } } else { @@ -218,11 +221,11 @@ internal final class _DataStorage { /* Try again with minimum length */ if newBytes == nil { newCapacity = malloc_good_size(newLength) - allocateCleared = clear && _DataStorage.shouldAllocateCleared(newCapacity) + allocateCleared = clear && __DataStorage.shouldAllocateCleared(newCapacity) if allocateCleared && tryCalloc { - newBytes = _DataStorage.allocate(newCapacity, true) + newBytes = __DataStorage.allocate(newCapacity, true) if let newBytes = newBytes { - _DataStorage.move(newBytes, _bytes!, origLength) + __DataStorage.move(newBytes, _bytes!, origLength) _freeBytes() } } @@ -293,10 +296,10 @@ internal final class _DataStorage { ensureUniqueBufferReference(growingTo: newLength, clear: false) } _length = newLength - _DataStorage.move(_bytes!.advanced(by: origLength), bytes, length) + __DataStorage.move(_bytes!.advanced(by: origLength), bytes, length) } - @inlinable // This is @inlinable despite escaping the _DataStorage boundary layer because it is trivially computed. + @inlinable // This is @inlinable despite escaping the __DataStorage boundary layer because it is trivially computed. func get(_ index: Int) -> UInt8 { return _bytes!.advanced(by: index - _offset).assumingMemoryBound(to: UInt8.self).pointee } @@ -364,14 +367,14 @@ internal final class _DataStorage { @usableFromInline // This is not @inlinable as a non-trivial, non-convenience initializer. init(length: Int) { - precondition(length < _DataStorage.maxSize) + precondition(length < __DataStorage.maxSize) var capacity = (length < 1024 * 1024 * 1024) ? length + (length >> 2) : length - if _DataStorage.vmOpsThreshold <= capacity { + if __DataStorage.vmOpsThreshold <= capacity { capacity = NSRoundUpToMultipleOfPageSize(capacity) } - let clear = _DataStorage.shouldAllocateCleared(length) - _bytes = _DataStorage.allocate(capacity, clear)! + let clear = __DataStorage.shouldAllocateCleared(length) + _bytes = __DataStorage.allocate(capacity, clear)! _capacity = capacity _needToZero = !clear _length = 0 @@ -382,12 +385,12 @@ internal final class _DataStorage { @usableFromInline // This is not @inlinable as a non-convience initializer. init(capacity capacity_: Int = 0) { var capacity = capacity_ - precondition(capacity < _DataStorage.maxSize) - if _DataStorage.vmOpsThreshold <= capacity { + precondition(capacity < __DataStorage.maxSize) + if __DataStorage.vmOpsThreshold <= capacity { capacity = NSRoundUpToMultipleOfPageSize(capacity) } _length = 0 - _bytes = _DataStorage.allocate(capacity, false)! + _bytes = __DataStorage.allocate(capacity, false)! _capacity = capacity _needToZero = true _offset = 0 @@ -395,35 +398,35 @@ internal final class _DataStorage { @usableFromInline // This is not @inlinable as a non-convience initializer. init(bytes: UnsafeRawPointer?, length: Int) { - precondition(length < _DataStorage.maxSize) + precondition(length < __DataStorage.maxSize) _offset = 0 if length == 0 { _capacity = 0 _length = 0 _needToZero = false _bytes = nil - } else if _DataStorage.vmOpsThreshold <= length { + } else if __DataStorage.vmOpsThreshold <= length { _capacity = length _length = length _needToZero = true - _bytes = _DataStorage.allocate(length, false)! - _DataStorage.move(_bytes!, bytes, length) + _bytes = __DataStorage.allocate(length, false)! + __DataStorage.move(_bytes!, bytes, length) } else { var capacity = length - if _DataStorage.vmOpsThreshold <= capacity { + if __DataStorage.vmOpsThreshold <= capacity { capacity = NSRoundUpToMultipleOfPageSize(capacity) } _length = length - _bytes = _DataStorage.allocate(capacity, false)! + _bytes = __DataStorage.allocate(capacity, false)! _capacity = capacity _needToZero = true - _DataStorage.move(_bytes!, bytes, length) + __DataStorage.move(_bytes!, bytes, length) } } @usableFromInline // This is not @inlinable as a non-convience initializer. init(bytes: UnsafeMutableRawPointer?, length: Int, copy: Bool, deallocator: ((UnsafeMutableRawPointer, Int) -> Void)?, offset: Int) { - precondition(length < _DataStorage.maxSize) + precondition(length < __DataStorage.maxSize) _offset = offset if length == 0 { _capacity = 0 @@ -440,25 +443,25 @@ internal final class _DataStorage { _needToZero = false _bytes = bytes _deallocator = deallocator - } else if _DataStorage.vmOpsThreshold <= length { + } else if __DataStorage.vmOpsThreshold <= length { _capacity = length _length = length _needToZero = true - _bytes = _DataStorage.allocate(length, false)! - _DataStorage.move(_bytes!, bytes, length) + _bytes = __DataStorage.allocate(length, false)! + __DataStorage.move(_bytes!, bytes, length) if let dealloc = deallocator { dealloc(bytes!, length) } } else { var capacity = length - if _DataStorage.vmOpsThreshold <= capacity { + if __DataStorage.vmOpsThreshold <= capacity { capacity = NSRoundUpToMultipleOfPageSize(capacity) } _length = length - _bytes = _DataStorage.allocate(capacity, false)! + _bytes = __DataStorage.allocate(capacity, false)! _capacity = capacity _needToZero = true - _DataStorage.move(_bytes!, bytes, length) + __DataStorage.move(_bytes!, bytes, length) if let dealloc = deallocator { dealloc(bytes!, length) } @@ -517,9 +520,9 @@ internal final class _DataStorage { _freeBytes() } - @inlinable // This is @inlinable despite escaping the _DataStorage boundary layer because it is trivially computed. - func mutableCopy(_ range: Range) -> _DataStorage { - return _DataStorage(bytes: _bytes?.advanced(by: range.lowerBound - _offset), length: range.upperBound - range.lowerBound, copy: true, deallocator: nil, offset: range.lowerBound) + @inlinable // This is @inlinable despite escaping the __DataStorage boundary layer because it is trivially computed. + func mutableCopy(_ range: Range) -> __DataStorage { + return __DataStorage(bytes: _bytes?.advanced(by: range.lowerBound - _offset), length: range.upperBound - range.lowerBound, copy: true, deallocator: nil, offset: range.lowerBound) } @inlinable // This is @inlinable despite escaping the _DataStorage boundary layer because it is generic and trivially computed. @@ -541,14 +544,14 @@ internal final class _DataStorage { } } -// NOTE: older runtimes called this _NSSwiftData. The two must +// NOTE: older overlays called this _NSSwiftData. The two must // coexist, so it was renamed. The old name must not be used in the new // runtime. internal class __NSSwiftData : NSData { - var _backing: _DataStorage! + var _backing: __DataStorage! var _range: Range! - convenience init(backing: _DataStorage, range: Range) { + convenience init(backing: __DataStorage, range: Range) { self.init() _backing = backing _range = range @@ -841,7 +844,7 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl // ***WARNING*** // These ivars are specifically laid out so that they cause the enum _Representation to be 16 bytes on 64 bit platforms. This means we _MUST_ have the class type thing last @usableFromInline var slice: Range - @usableFromInline var storage: _DataStorage + @usableFromInline var storage: __DataStorage @inlinable // This is @inlinable as trivially computable. static func canStore(count: Int) -> Bool { @@ -851,32 +854,32 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl @inlinable // This is @inlinable as a convenience initializer. init(_ buffer: UnsafeRawBufferPointer) { assert(buffer.count < HalfInt.max) - self.init(_DataStorage(bytes: buffer.baseAddress, length: buffer.count), count: buffer.count) + self.init(__DataStorage(bytes: buffer.baseAddress, length: buffer.count), count: buffer.count) } @inlinable // This is @inlinable as a convenience initializer. init(capacity: Int) { assert(capacity < HalfInt.max) - self.init(_DataStorage(capacity: capacity), count: 0) + self.init(__DataStorage(capacity: capacity), count: 0) } @inlinable // This is @inlinable as a convenience initializer. init(count: Int) { assert(count < HalfInt.max) - self.init(_DataStorage(length: count), count: count) + self.init(__DataStorage(length: count), count: count) } @inlinable // This is @inlinable as a convenience initializer. init(_ inline: InlineData) { assert(inline.count < HalfInt.max) - self.init(inline.withUnsafeBytes { return _DataStorage(bytes: $0.baseAddress, length: $0.count) }, count: inline.count) + self.init(inline.withUnsafeBytes { return __DataStorage(bytes: $0.baseAddress, length: $0.count) }, count: inline.count) } @inlinable // This is @inlinable as a convenience initializer. init(_ inline: InlineData, range: Range) { assert(range.lowerBound < HalfInt.max) assert(range.upperBound < HalfInt.max) - self.init(inline.withUnsafeBytes { return _DataStorage(bytes: $0.baseAddress, length: $0.count) }, range: range) + self.init(inline.withUnsafeBytes { return __DataStorage(bytes: $0.baseAddress, length: $0.count) }, range: range) } @inlinable // This is @inlinable as a convenience initializer. @@ -894,14 +897,14 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl } @inlinable // This is @inlinable as a trivial initializer. - init(_ storage: _DataStorage, count: Int) { + init(_ storage: __DataStorage, count: Int) { assert(count < HalfInt.max) self.storage = storage slice = 0..) { + init(_ storage: __DataStorage, range: Range) { assert(range.lowerBound < HalfInt.max) assert(range.upperBound < HalfInt.max) self.storage = storage @@ -1087,26 +1090,26 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl // ***WARNING*** // These ivars are specifically laid out so that they cause the enum _Representation to be 16 bytes on 64 bit platforms. This means we _MUST_ have the class type thing last @usableFromInline var slice: RangeReference - @usableFromInline var storage: _DataStorage + @usableFromInline var storage: __DataStorage @inlinable // This is @inlinable as a convenience initializer. init(_ buffer: UnsafeRawBufferPointer) { - self.init(_DataStorage(bytes: buffer.baseAddress, length: buffer.count), count: buffer.count) + self.init(__DataStorage(bytes: buffer.baseAddress, length: buffer.count), count: buffer.count) } @inlinable // This is @inlinable as a convenience initializer. init(capacity: Int) { - self.init(_DataStorage(capacity: capacity), count: 0) + self.init(__DataStorage(capacity: capacity), count: 0) } @inlinable // This is @inlinable as a convenience initializer. init(count: Int) { - self.init(_DataStorage(length: count), count: count) + self.init(__DataStorage(length: count), count: count) } @inlinable // This is @inlinable as a convenience initializer. init(_ inline: InlineData) { - let storage = inline.withUnsafeBytes { return _DataStorage(bytes: $0.baseAddress, length: $0.count) } + let storage = inline.withUnsafeBytes { return __DataStorage(bytes: $0.baseAddress, length: $0.count) } self.init(storage, count: inline.count) } @@ -1117,7 +1120,7 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl } @inlinable // This is @inlinable as a trivial initializer. - init(_ storage: _DataStorage, count: Int) { + init(_ storage: __DataStorage, count: Int) { self.storage = storage self.slice = RangeReference(0..(_ value: T) throws -> Data { - let encoder = _JSONEncoder(options: self.options) + let encoder = __JSONEncoder(options: self.options) guard let topLevel = try encoder.box_(value) else { throw EncodingError.invalidValue(value, @@ -273,9 +278,12 @@ open class JSONEncoder { } } -// MARK: - _JSONEncoder +// MARK: - __JSONEncoder -fileprivate class _JSONEncoder : Encoder { +// NOTE: older overlays called this class _JSONEncoder. +// The two must coexist without a conflicting ObjC class name, so it +// was renamed. The old name must not be used in the new runtime. +fileprivate class __JSONEncoder : Encoder { // MARK: Properties /// The encoder's storage. @@ -405,7 +413,7 @@ fileprivate struct _JSONKeyedEncodingContainer : KeyedEncodingCon // MARK: Properties /// A reference to the encoder we're writing to. - private let encoder: _JSONEncoder + private let encoder: __JSONEncoder /// A reference to the container we're writing to. private let container: NSMutableDictionary @@ -416,7 +424,7 @@ fileprivate struct _JSONKeyedEncodingContainer : KeyedEncodingCon // MARK: - Initialization /// Initializes `self` with the given references. - fileprivate init(referencing encoder: _JSONEncoder, codingPath: [CodingKey], wrapping container: NSMutableDictionary) { + fileprivate init(referencing encoder: __JSONEncoder, codingPath: [CodingKey], wrapping container: NSMutableDictionary) { self.encoder = encoder self.codingPath = codingPath self.container = container @@ -519,11 +527,11 @@ fileprivate struct _JSONKeyedEncodingContainer : KeyedEncodingCon } public mutating func superEncoder() -> Encoder { - return _JSONReferencingEncoder(referencing: self.encoder, key: _JSONKey.super, convertedKey: _converted(_JSONKey.super), wrapping: self.container) + return __JSONReferencingEncoder(referencing: self.encoder, key: _JSONKey.super, convertedKey: _converted(_JSONKey.super), wrapping: self.container) } public mutating func superEncoder(forKey key: Key) -> Encoder { - return _JSONReferencingEncoder(referencing: self.encoder, key: key, convertedKey: _converted(key), wrapping: self.container) + return __JSONReferencingEncoder(referencing: self.encoder, key: key, convertedKey: _converted(key), wrapping: self.container) } } @@ -531,7 +539,7 @@ fileprivate struct _JSONUnkeyedEncodingContainer : UnkeyedEncodingContainer { // MARK: Properties /// A reference to the encoder we're writing to. - private let encoder: _JSONEncoder + private let encoder: __JSONEncoder /// A reference to the container we're writing to. private let container: NSMutableArray @@ -547,7 +555,7 @@ fileprivate struct _JSONUnkeyedEncodingContainer : UnkeyedEncodingContainer { // MARK: - Initialization /// Initializes `self` with the given references. - fileprivate init(referencing encoder: _JSONEncoder, codingPath: [CodingKey], wrapping container: NSMutableArray) { + fileprivate init(referencing encoder: __JSONEncoder, codingPath: [CodingKey], wrapping container: NSMutableArray) { self.encoder = encoder self.codingPath = codingPath self.container = container @@ -610,11 +618,11 @@ fileprivate struct _JSONUnkeyedEncodingContainer : UnkeyedEncodingContainer { } public mutating func superEncoder() -> Encoder { - return _JSONReferencingEncoder(referencing: self.encoder, at: self.container.count, wrapping: self.container) + return __JSONReferencingEncoder(referencing: self.encoder, at: self.container.count, wrapping: self.container) } } -extension _JSONEncoder : SingleValueEncodingContainer { +extension __JSONEncoder : SingleValueEncodingContainer { // MARK: - SingleValueEncodingContainer Methods fileprivate func assertCanEncodeNewValue() { @@ -704,7 +712,7 @@ extension _JSONEncoder : SingleValueEncodingContainer { // MARK: - Concrete Value Representations -extension _JSONEncoder { +extension __JSONEncoder { /// Returns the given value boxed in a container appropriate for pushing onto the container stack. fileprivate func box(_ value: Bool) -> NSObject { return NSNumber(value: value) } fileprivate func box(_ value: Int) -> NSObject { return NSNumber(value: value) } @@ -902,7 +910,7 @@ extension _JSONEncoder { return try self.box(value as! [String : Encodable]) } - // The value should request a container from the _JSONEncoder. + // The value should request a container from the __JSONEncoder. let depth = self.storage.count do { try value.encode(to: self) @@ -924,11 +932,14 @@ extension _JSONEncoder { } } -// MARK: - _JSONReferencingEncoder +// MARK: - __JSONReferencingEncoder -/// _JSONReferencingEncoder is a special subclass of _JSONEncoder which has its own storage, but references the contents of a different encoder. +/// __JSONReferencingEncoder is a special subclass of __JSONEncoder which has its own storage, but references the contents of a different encoder. /// It's used in superEncoder(), which returns a new encoder for encoding a superclass -- the lifetime of the encoder should not escape the scope it's created in, but it doesn't necessarily know when it's done being used (to write to the original container). -fileprivate class _JSONReferencingEncoder : _JSONEncoder { +// NOTE: older overlays called this class _JSONReferencingEncoder. +// The two must coexist without a conflicting ObjC class name, so it +// was renamed. The old name must not be used in the new runtime. +fileprivate class __JSONReferencingEncoder : __JSONEncoder { // MARK: Reference types. /// The type of container we're referencing. @@ -943,7 +954,7 @@ fileprivate class _JSONReferencingEncoder : _JSONEncoder { // MARK: - Properties /// The encoder we're referencing. - fileprivate let encoder: _JSONEncoder + fileprivate let encoder: __JSONEncoder /// The container reference itself. private let reference: Reference @@ -951,7 +962,7 @@ fileprivate class _JSONReferencingEncoder : _JSONEncoder { // MARK: - Initialization /// Initializes `self` by referencing the given array container in the given encoder. - fileprivate init(referencing encoder: _JSONEncoder, at index: Int, wrapping array: NSMutableArray) { + fileprivate init(referencing encoder: __JSONEncoder, at index: Int, wrapping array: NSMutableArray) { self.encoder = encoder self.reference = .array(array, index) super.init(options: encoder.options, codingPath: encoder.codingPath) @@ -960,7 +971,7 @@ fileprivate class _JSONReferencingEncoder : _JSONEncoder { } /// Initializes `self` by referencing the given dictionary container in the given encoder. - fileprivate init(referencing encoder: _JSONEncoder, + fileprivate init(referencing encoder: __JSONEncoder, key: CodingKey, convertedKey: __shared CodingKey, wrapping dictionary: NSMutableDictionary) { self.encoder = encoder self.reference = .dictionary(dictionary, convertedKey.stringValue) @@ -1004,6 +1015,11 @@ fileprivate class _JSONReferencingEncoder : _JSONEncoder { //===----------------------------------------------------------------------===// /// `JSONDecoder` facilitates the decoding of JSON into semantic `Decodable` types. +// NOTE: older overlays had Foundation.JSONDecoder as the ObjC name. +// The two must coexist, so it was renamed. The old name must not be +// used in the new runtime. _TtC10Foundation12_JSONDecoder is the +// mangled name for Foundation._JSONDecoder. +@_objcRuntimeName(_TtC10Foundation12_JSONDecoder) open class JSONDecoder { // MARK: Options diff --git a/stdlib/public/Darwin/Foundation/NSDictionary.swift b/stdlib/public/Darwin/Foundation/NSDictionary.swift index 2b5b58b5bd179..90be2e49a9993 100644 --- a/stdlib/public/Darwin/Foundation/NSDictionary.swift +++ b/stdlib/public/Darwin/Foundation/NSDictionary.swift @@ -348,6 +348,11 @@ extension NSDictionary : _HasCustomAnyHashableRepresentation { extension NSDictionary : Sequence { // FIXME: A class because we can't pass a struct with class fields through an // [objc] interface without prematurely destroying the references. + // NOTE: older runtimes had + // _TtCE10FoundationCSo12NSDictionary8Iterator as the ObjC name. The + // two must coexist, so it was renamed. The old name must not be used + // in the new runtime. + @_objcRuntimeName(_TtCE10FoundationCSo12NSDictionary9_Iterator) final public class Iterator : IteratorProtocol { var _fastIterator: NSFastEnumerationIterator var _dictionary: NSDictionary { diff --git a/stdlib/public/Darwin/Foundation/NSError.swift b/stdlib/public/Darwin/Foundation/NSError.swift index 6c4c21285be01..57a238566b6c4 100644 --- a/stdlib/public/Darwin/Foundation/NSError.swift +++ b/stdlib/public/Darwin/Foundation/NSError.swift @@ -74,7 +74,10 @@ public extension LocalizedError { /// Class that implements the informal protocol /// NSErrorRecoveryAttempting, which is used by NSError when it /// attempts recovery from an error. -class _NSErrorRecoveryAttempter { +// NOTE: older overlays called this class _NSErrorRecoveryAttempter. +// The two must coexist without a conflicting ObjC class name, so it +// was renamed. The old name must not be used in the new runtime. +class __NSErrorRecoveryAttempter { @objc(attemptRecoveryFromError:optionIndex:delegate:didRecoverSelector:contextInfo:) func attemptRecovery(fromError nsError: NSError, optionIndex recoveryOptionIndex: Int, @@ -252,7 +255,7 @@ public func _getErrorDefaultUserInfo(_ error: T) case NSRecoveryAttempterErrorKey: if error is RecoverableError { - return _NSErrorRecoveryAttempter() + return __NSErrorRecoveryAttempter() } return nil @@ -308,7 +311,7 @@ public func _getErrorDefaultUserInfo(_ error: T) let recoverableError = error as? RecoverableError { result[NSLocalizedRecoveryOptionsErrorKey] = recoverableError.recoveryOptions - result[NSRecoveryAttempterErrorKey] = _NSErrorRecoveryAttempter() + result[NSRecoveryAttempterErrorKey] = __NSErrorRecoveryAttempter() } return result as AnyObject diff --git a/stdlib/public/Darwin/Foundation/PlistEncoder.swift b/stdlib/public/Darwin/Foundation/PlistEncoder.swift index 151f2750afac4..8480c8563c8b6 100644 --- a/stdlib/public/Darwin/Foundation/PlistEncoder.swift +++ b/stdlib/public/Darwin/Foundation/PlistEncoder.swift @@ -15,6 +15,11 @@ //===----------------------------------------------------------------------===// /// `PropertyListEncoder` facilitates the encoding of `Encodable` values into property lists. +// NOTE: older overlays had Foundation.PropertyListEncoder as the ObjC +// name. The two must coexist, so it was renamed. The old name must not +// be used in the new runtime. _TtC10Foundation20_PropertyListEncoder +// is the mangled name for Foundation._PropertyListEncoder. +@_objcRuntimeName(_TtC10Foundation20_PropertyListEncoder) open class PropertyListEncoder { // MARK: - Options @@ -80,7 +85,7 @@ open class PropertyListEncoder { /// - throws: `EncodingError.invalidValue` if a non-conforming floating-point value is encountered during encoding, and the encoding strategy is `.throw`. /// - throws: An error if any value throws an error during encoding. internal func encodeToTopLevelContainer(_ value: Value) throws -> Any { - let encoder = _PlistEncoder(options: self.options) + let encoder = __PlistEncoder(options: self.options) guard let topLevel = try encoder.box_(value) else { throw EncodingError.invalidValue(value, EncodingError.Context(codingPath: [], @@ -91,9 +96,12 @@ open class PropertyListEncoder { } } -// MARK: - _PlistEncoder +// MARK: - __PlistEncoder -fileprivate class _PlistEncoder : Encoder { +// NOTE: older overlays called this class _PlistEncoder. The two must +// coexist without a conflicting ObjC class name, so it was renamed. +// The old name must not be used in the new runtime. +fileprivate class __PlistEncoder : Encoder { // MARK: Properties /// The encoder's storage. @@ -223,7 +231,7 @@ fileprivate struct _PlistKeyedEncodingContainer : KeyedEncodingCo // MARK: Properties /// A reference to the encoder we're writing to. - private let encoder: _PlistEncoder + private let encoder: __PlistEncoder /// A reference to the container we're writing to. private let container: NSMutableDictionary @@ -234,7 +242,7 @@ fileprivate struct _PlistKeyedEncodingContainer : KeyedEncodingCo // MARK: - Initialization /// Initializes `self` with the given references. - fileprivate init(referencing encoder: _PlistEncoder, codingPath: [CodingKey], wrapping container: NSMutableDictionary) { + fileprivate init(referencing encoder: __PlistEncoder, codingPath: [CodingKey], wrapping container: NSMutableDictionary) { self.encoder = encoder self.codingPath = codingPath self.container = container @@ -285,11 +293,11 @@ fileprivate struct _PlistKeyedEncodingContainer : KeyedEncodingCo } public mutating func superEncoder() -> Encoder { - return _PlistReferencingEncoder(referencing: self.encoder, at: _PlistKey.super, wrapping: self.container) + return __PlistReferencingEncoder(referencing: self.encoder, at: _PlistKey.super, wrapping: self.container) } public mutating func superEncoder(forKey key: Key) -> Encoder { - return _PlistReferencingEncoder(referencing: self.encoder, at: key, wrapping: self.container) + return __PlistReferencingEncoder(referencing: self.encoder, at: key, wrapping: self.container) } } @@ -297,7 +305,7 @@ fileprivate struct _PlistUnkeyedEncodingContainer : UnkeyedEncodingContainer { // MARK: Properties /// A reference to the encoder we're writing to. - private let encoder: _PlistEncoder + private let encoder: __PlistEncoder /// A reference to the container we're writing to. private let container: NSMutableArray @@ -313,7 +321,7 @@ fileprivate struct _PlistUnkeyedEncodingContainer : UnkeyedEncodingContainer { // MARK: - Initialization /// Initializes `self` with the given references. - fileprivate init(referencing encoder: _PlistEncoder, codingPath: [CodingKey], wrapping container: NSMutableArray) { + fileprivate init(referencing encoder: __PlistEncoder, codingPath: [CodingKey], wrapping container: NSMutableArray) { self.encoder = encoder self.codingPath = codingPath self.container = container @@ -364,11 +372,11 @@ fileprivate struct _PlistUnkeyedEncodingContainer : UnkeyedEncodingContainer { } public mutating func superEncoder() -> Encoder { - return _PlistReferencingEncoder(referencing: self.encoder, at: self.container.count, wrapping: self.container) + return __PlistReferencingEncoder(referencing: self.encoder, at: self.container.count, wrapping: self.container) } } -extension _PlistEncoder : SingleValueEncodingContainer { +extension __PlistEncoder : SingleValueEncodingContainer { // MARK: - SingleValueEncodingContainer Methods private func assertCanEncodeNewValue() { @@ -458,7 +466,7 @@ extension _PlistEncoder : SingleValueEncodingContainer { // MARK: - Concrete Value Representations -extension _PlistEncoder { +extension __PlistEncoder { /// Returns the given value boxed in a container appropriate for pushing onto the container stack. fileprivate func box(_ value: Bool) -> NSObject { return NSNumber(value: value) } @@ -489,7 +497,7 @@ extension _PlistEncoder { return (value as! NSData) } - // The value should request a container from the _PlistEncoder. + // The value should request a container from the __PlistEncoder. let depth = self.storage.count do { try value.encode(to: self) @@ -511,11 +519,14 @@ extension _PlistEncoder { } } -// MARK: - _PlistReferencingEncoder +// MARK: - __PlistReferencingEncoder -/// _PlistReferencingEncoder is a special subclass of _PlistEncoder which has its own storage, but references the contents of a different encoder. +/// __PlistReferencingEncoder is a special subclass of __PlistEncoder which has its own storage, but references the contents of a different encoder. /// It's used in superEncoder(), which returns a new encoder for encoding a superclass -- the lifetime of the encoder should not escape the scope it's created in, but it doesn't necessarily know when it's done being used (to write to the original container). -fileprivate class _PlistReferencingEncoder : _PlistEncoder { +// NOTE: older overlays called this class _PlistReferencingEncoder. +// The two must coexist without a conflicting ObjC class name, so it +// was renamed. The old name must not be used in the new runtime. +fileprivate class __PlistReferencingEncoder : __PlistEncoder { // MARK: Reference types. /// The type of container we're referencing. @@ -530,7 +541,7 @@ fileprivate class _PlistReferencingEncoder : _PlistEncoder { // MARK: - Properties /// The encoder we're referencing. - private let encoder: _PlistEncoder + private let encoder: __PlistEncoder /// The container reference itself. private let reference: Reference @@ -538,7 +549,7 @@ fileprivate class _PlistReferencingEncoder : _PlistEncoder { // MARK: - Initialization /// Initializes `self` by referencing the given array container in the given encoder. - fileprivate init(referencing encoder: _PlistEncoder, at index: Int, wrapping array: NSMutableArray) { + fileprivate init(referencing encoder: __PlistEncoder, at index: Int, wrapping array: NSMutableArray) { self.encoder = encoder self.reference = .array(array, index) super.init(options: encoder.options, codingPath: encoder.codingPath) @@ -547,7 +558,7 @@ fileprivate class _PlistReferencingEncoder : _PlistEncoder { } /// Initializes `self` by referencing the given dictionary container in the given encoder. - fileprivate init(referencing encoder: _PlistEncoder, at key: CodingKey, wrapping dictionary: NSMutableDictionary) { + fileprivate init(referencing encoder: __PlistEncoder, at key: CodingKey, wrapping dictionary: NSMutableDictionary) { self.encoder = encoder self.reference = .dictionary(dictionary, key.stringValue) super.init(options: encoder.options, codingPath: encoder.codingPath) @@ -590,6 +601,11 @@ fileprivate class _PlistReferencingEncoder : _PlistEncoder { //===----------------------------------------------------------------------===// /// `PropertyListDecoder` facilitates the decoding of property list values into semantic `Decodable` types. +// NOTE: older overlays had Foundation.PropertyListDecoder as the ObjC +// name. The two must coexist, so it was renamed. The old name must not +// be used in the new runtime. _TtC10Foundation20_PropertyListDecoder +// is the mangled name for Foundation._PropertyListDecoder. +@_objcRuntimeName(_TtC10Foundation20_PropertyListDecoder) open class PropertyListDecoder { // MARK: Options @@ -652,7 +668,7 @@ open class PropertyListDecoder { /// - throws: `DecodingError.dataCorrupted` if values requested from the payload are corrupted, or if the given data is not a valid property list. /// - throws: An error if any value throws an error during decoding. internal func decode(_ type: T.Type, fromTopLevel container: Any) throws -> T { - let decoder = _PlistDecoder(referencing: container, options: self.options) + let decoder = __PlistDecoder(referencing: container, options: self.options) guard let value = try decoder.unbox(container, as: type) else { throw DecodingError.valueNotFound(type, DecodingError.Context(codingPath: [], debugDescription: "The given data did not contain a top-level value.")) } @@ -661,9 +677,12 @@ open class PropertyListDecoder { } } -// MARK: - _PlistDecoder +// MARK: - __PlistDecoder -fileprivate class _PlistDecoder : Decoder { +// NOTE: older overlays called this class _PlistDecoder. The two must +// coexist without a conflicting ObjC class name, so it was renamed. +// The old name must not be used in the new runtime. +fileprivate class __PlistDecoder : Decoder { // MARK: Properties /// The decoder's storage. @@ -769,7 +788,7 @@ fileprivate struct _PlistKeyedDecodingContainer : KeyedDecodingCo // MARK: Properties /// A reference to the decoder we're reading from. - private let decoder: _PlistDecoder + private let decoder: __PlistDecoder /// A reference to the container we're reading from. private let container: [String : Any] @@ -780,7 +799,7 @@ fileprivate struct _PlistKeyedDecodingContainer : KeyedDecodingCo // MARK: - Initialization /// Initializes `self` by referencing the given decoder and container. - fileprivate init(referencing decoder: _PlistDecoder, wrapping container: [String : Any]) { + fileprivate init(referencing decoder: __PlistDecoder, wrapping container: [String : Any]) { self.decoder = decoder self.container = container self.codingPath = decoder.codingPath @@ -1072,7 +1091,7 @@ fileprivate struct _PlistKeyedDecodingContainer : KeyedDecodingCo defer { self.decoder.codingPath.removeLast() } let value: Any = self.container[key.stringValue] ?? NSNull() - return _PlistDecoder(referencing: value, at: self.decoder.codingPath, options: self.decoder.options) + return __PlistDecoder(referencing: value, at: self.decoder.codingPath, options: self.decoder.options) } public func superDecoder() throws -> Decoder { @@ -1088,7 +1107,7 @@ fileprivate struct _PlistUnkeyedDecodingContainer : UnkeyedDecodingContainer { // MARK: Properties /// A reference to the decoder we're reading from. - private let decoder: _PlistDecoder + private let decoder: __PlistDecoder /// A reference to the container we're reading from. private let container: [Any] @@ -1102,7 +1121,7 @@ fileprivate struct _PlistUnkeyedDecodingContainer : UnkeyedDecodingContainer { // MARK: - Initialization /// Initializes `self` by referencing the given decoder and container. - fileprivate init(referencing decoder: _PlistDecoder, wrapping container: [Any]) { + fileprivate init(referencing decoder: __PlistDecoder, wrapping container: [Any]) { self.decoder = decoder self.container = container self.codingPath = decoder.codingPath @@ -1434,11 +1453,11 @@ fileprivate struct _PlistUnkeyedDecodingContainer : UnkeyedDecodingContainer { let value = self.container[self.currentIndex] self.currentIndex += 1 - return _PlistDecoder(referencing: value, at: self.decoder.codingPath, options: self.decoder.options) + return __PlistDecoder(referencing: value, at: self.decoder.codingPath, options: self.decoder.options) } } -extension _PlistDecoder : SingleValueDecodingContainer { +extension __PlistDecoder : SingleValueDecodingContainer { // MARK: SingleValueDecodingContainer Methods private func expectNonNull(_ type: T.Type) throws { @@ -1533,7 +1552,7 @@ extension _PlistDecoder : SingleValueDecodingContainer { // MARK: - Concrete Value Representations -extension _PlistDecoder { +extension __PlistDecoder { /// Returns the given value unboxed from a container. fileprivate func unbox(_ value: Any, as type: Bool.Type) throws -> Bool? { if let string = value as? String, string == _plistNull { return nil } diff --git a/stdlib/public/Darwin/Network/NWConnection.swift b/stdlib/public/Darwin/Network/NWConnection.swift index 64e235507abb1..8834ed634d14d 100644 --- a/stdlib/public/Darwin/Network/NWConnection.swift +++ b/stdlib/public/Darwin/Network/NWConnection.swift @@ -20,6 +20,11 @@ import _SwiftNetworkOverlayShims /// A connection handles establishment of any transport, security, or application-level protocols /// required to transmit and receive user data. Multiple protocol instances may be attempted during /// the establishment phase of the connection. +// NOTE: older overlays had Network.NWConnection as the ObjC name. +// The two must coexist, so it was renamed. The old name must not be +// used in the new runtime. _TtC7Network13_NWConnection is the +// mangled name for Network._NWConnection. +@_objcRuntimeName(_TtC7Network13_NWConnection) @available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *) public final class NWConnection : CustomDebugStringConvertible { @@ -306,6 +311,8 @@ public final class NWConnection : CustomDebugStringConvertible { /// Content Context controls options for how data is sent, and access for metadata to send or receive. /// All properties of Content Context are valid for sending. For received Content Context, only the protocolMetadata /// values will be set. + // Set the ObjC name of this class to be nested in the customized ObjC name of NWConnection. + @_objcRuntimeName(_TtCC7Network13_NWConnection14ContentContext) public class ContentContext { internal let nw: nw_content_context_t diff --git a/stdlib/public/Darwin/Network/NWListener.swift b/stdlib/public/Darwin/Network/NWListener.swift index e12a560f9b9d9..87e0e0a18b7e9 100644 --- a/stdlib/public/Darwin/Network/NWListener.swift +++ b/stdlib/public/Darwin/Network/NWListener.swift @@ -22,6 +22,11 @@ import Foundation /// accepted connections will represent multiplexed streams on a new or existing transport /// binding. +// NOTE: older overlays had Network.NWListener as the ObjC name. +// The two must coexist, so it was renamed. The old name must not be +// used in the new runtime. _TtC7Network11_NWListener is the +// mangled name for Network._NWListener. +@_objcRuntimeName(_TtC7Network11_NWListener) @available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *) public final class NWListener: CustomDebugStringConvertible { public var debugDescription: String { diff --git a/stdlib/public/Darwin/Network/NWParameters.swift b/stdlib/public/Darwin/Network/NWParameters.swift index 9880f8b8577e3..face2df7c8989 100644 --- a/stdlib/public/Darwin/Network/NWParameters.swift +++ b/stdlib/public/Darwin/Network/NWParameters.swift @@ -16,6 +16,11 @@ /// endpoint requirements); preferences for data transfer and quality of service; /// and the protocols to be used for a connection along with any protocol-specific /// options. +// NOTE: older overlays had Network.NWParameters as the ObjC name. +// The two must coexist, so it was renamed. The old name must not be +// used in the new runtime. _TtC7Network13_NWParameters is the +// mangled name for Network._NWParameters. +@_objcRuntimeName(_TtC7Network13_NWParameters) @available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *) public final class NWParameters : CustomDebugStringConvertible { public var debugDescription: String { @@ -422,6 +427,9 @@ public final class NWParameters : CustomDebugStringConvertible { /// transport-level protocol, and an optional internet-level protocol. If the internet- /// level protocol is not specified, any available and applicable IP address family /// may be used. + // Set the ObjC name of this class to be nested in the customized ObjC + // name of NWParameters. + @_objcRuntimeName(_TtCC7Network13_NWParameters13ProtocolStack) public class ProtocolStack { public var applicationProtocols: [NWProtocolOptions] { set { diff --git a/stdlib/public/Darwin/Network/NWPath.swift b/stdlib/public/Darwin/Network/NWPath.swift index 437aa0c23e699..000552a7503a6 100644 --- a/stdlib/public/Darwin/Network/NWPath.swift +++ b/stdlib/public/Darwin/Network/NWPath.swift @@ -225,6 +225,11 @@ public struct NWPath : Equatable, CustomDebugStringConvertible { /// The paths will watch the state of multiple interfaces, and allows the /// application to enumerate the available interfaces for use in creating connections /// or listeners bound to specific interfaces. +// NOTE: older overlays had Network.NWPathMonitor as the ObjC name. +// The two must coexist, so it was renamed. The old name must not be +// used in the new runtime. _TtC7Network14_NWPathMonitor is the +// mangled name for Network._NWPathMonitor. +@_objcRuntimeName(_TtC7Network14_NWPathMonitor) @available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *) public final class NWPathMonitor { diff --git a/stdlib/public/Darwin/Network/NWProtocol.swift b/stdlib/public/Darwin/Network/NWProtocol.swift index 15121944ae650..f05e30cf6c91b 100644 --- a/stdlib/public/Darwin/Network/NWProtocol.swift +++ b/stdlib/public/Darwin/Network/NWProtocol.swift @@ -12,6 +12,11 @@ /// NWProtocolDefinition is an abstract superclass that represents the identifier of a /// protocol that can be used with connections and listeners, such as TCP. +// NOTE: older overlays had Network.NWProtocolDefinition as the ObjC name. +// The two must coexist, so it was renamed. The old name must not be +// used in the new runtime. _TtC7Network21_NWProtocolDefinition is the +// mangled name for Network._NWProtocolDefinition. +@_objcRuntimeName(_TtC7Network21_NWProtocolDefinition) @available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *) public class NWProtocolDefinition : Equatable, CustomDebugStringConvertible { public static func == (lhs: NWProtocolDefinition, rhs: NWProtocolDefinition) -> Bool { @@ -35,6 +40,11 @@ public class NWProtocolDefinition : Equatable, CustomDebugStringConvertible { /// NWProtocolOptions is an abstract superclass that represents a configuration options /// that can be used to add a protocol into an NWParameters.ProtocolStack. These options /// configure the behavior of a protocol and cannot be changed after starting a connection. +// NOTE: older overlays had Network.NWProtocolOptions as the ObjC name. +// The two must coexist, so it was renamed. The old name must not be +// used in the new runtime. _TtC7Network18_NWProtocolOptions is the +// mangled name for Network._NWProtocolOptions. +@_objcRuntimeName(_TtC7Network18_NWProtocolOptions) @available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *) public class NWProtocolOptions { internal let nw: nw_protocol_options_t @@ -50,6 +60,11 @@ public class NWProtocolOptions { /// specific to some content being sent; as well as to retrieve metadata specific to some /// content that was received. Each protocol is responsible for defining its own accessor /// functions to set and get metadata. +// NOTE: older overlays had Network.NWProtocolMetadata as the ObjC name. +// The two must coexist, so it was renamed. The old name must not be +// used in the new runtime. _TtC7Network19_NWProtocolMetadata is the +// mangled name for Network._NWProtocolMetadata. +@_objcRuntimeName(_TtC7Network19_NWProtocolMetadata) @available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *) public class NWProtocolMetadata { internal let nw: nw_protocol_metadata_t @@ -60,6 +75,11 @@ public class NWProtocolMetadata { } /// NWProtocol is an abstract superclass to which protocol implementations conform. +// NOTE: older overlays had Network.NWProtocol as the ObjC name. +// The two must coexist, so it was renamed. The old name must not be +// used in the new runtime. _TtC7Network11_NWProtocol is the +// mangled name for Network._NWProtocol. +@_objcRuntimeName(_TtC7Network11_NWProtocol) @available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *) public class NWProtocol { diff --git a/stdlib/public/Darwin/Network/NWProtocolIP.swift b/stdlib/public/Darwin/Network/NWProtocolIP.swift index 45c78f257956e..1e585bb95e5b9 100644 --- a/stdlib/public/Darwin/Network/NWProtocolIP.swift +++ b/stdlib/public/Darwin/Network/NWProtocolIP.swift @@ -10,12 +10,20 @@ // //===----------------------------------------------------------------------===// +// NOTE: older overlays had Network.NWProtocolIP as the ObjC name. +// The two must coexist, so it was renamed. The old name must not be +// used in the new runtime. _TtC7Network13_NWProtocolIP is the +// mangled name for Network._NWProtocolIP. +@_objcRuntimeName(_TtC7Network13_NWProtocolIP) @available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *) public class NWProtocolIP : NWProtocol { public static let definition: NWProtocolDefinition = { NWProtocolDefinition(nw_protocol_copy_ip_definition(), "ip") }() + // Set the ObjC name of this class to be nested in the customized ObjC + // name of NWProtocolIP. + @_objcRuntimeName(_TtCC7Network13_NWProtocolIP7Options) public class Options : NWProtocolOptions { public enum Version { /// Allow any IP version @@ -167,6 +175,9 @@ public class NWProtocolIP : NWProtocol { } /// IP Metadata can be sent or received as part of ContentContext + // Set the ObjC name of this class to be nested in the customized ObjC + // name of NWProtocolIP. + @_objcRuntimeName(_TtCC7Network13_NWProtocolIP8Metadata) public class Metadata: NWProtocolMetadata { /// Set ECN flags to be sent on a packet, or get ECN flags /// received on a packet. These flags will not take effect diff --git a/stdlib/public/Darwin/Network/NWProtocolTCP.swift b/stdlib/public/Darwin/Network/NWProtocolTCP.swift index d85d5d727e3ed..f7968eb767644 100644 --- a/stdlib/public/Darwin/Network/NWProtocolTCP.swift +++ b/stdlib/public/Darwin/Network/NWProtocolTCP.swift @@ -10,12 +10,20 @@ // //===----------------------------------------------------------------------===// +// NOTE: older overlays had Network.NWProtocolTCP as the ObjC name. +// The two must coexist, so it was renamed. The old name must not be +// used in the new runtime. _TtC7Network14_NWProtocolTCP is the +// mangled name for Network._NWProtocolTCP. +@_objcRuntimeName(_TtC7Network14_NWProtocolTCP) @available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *) public class NWProtocolTCP : NWProtocol { public static let definition: NWProtocolDefinition = { NWProtocolDefinition(nw_protocol_copy_tcp_definition(), "tcp") }() + // Set the ObjC name of this class to be nested in the customized ObjC + // name of NWProtocolTCP. + @_objcRuntimeName(_TtCC7Network14_NWProtocolTCP7Options) public class Options : NWProtocolOptions { private var _noDelay: Bool = false @@ -244,6 +252,9 @@ public class NWProtocolTCP : NWProtocol { /// Access TCP metadata using NWConnection.metadata(protocolDefinition: NWProtocolTCP.definition) /// or in received ContentContext + // Set the ObjC name of this class to be nested in the customized ObjC + // name of NWProtocolTCP. + @_objcRuntimeName(_TtCC7Network14_NWProtocolTCP8Metadata) public class Metadata: NWProtocolMetadata { override internal init(_ nw: nw_protocol_metadata_t) { super.init(nw) diff --git a/stdlib/public/Darwin/Network/NWProtocolTLS.swift b/stdlib/public/Darwin/Network/NWProtocolTLS.swift index beb21fa9c3175..0522d8d3f29c4 100644 --- a/stdlib/public/Darwin/Network/NWProtocolTLS.swift +++ b/stdlib/public/Darwin/Network/NWProtocolTLS.swift @@ -10,12 +10,20 @@ // //===----------------------------------------------------------------------===// +// NOTE: older overlays had Network.NWProtocolTLS as the ObjC name. +// The two must coexist, so it was renamed. The old name must not be +// used in the new runtime. _TtC7Network14_NWProtocolTLS is the +// mangled name for Network._NWProtocolTLS. +@_objcRuntimeName(_TtC7Network14_NWProtocolTLS) @available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *) public class NWProtocolTLS : NWProtocol { public static let definition: NWProtocolDefinition = { NWProtocolDefinition(nw_protocol_copy_tls_definition(), "tls") }() + // Set the ObjC name of this class to be nested in the customized ObjC + // name of NWProtocolTLS. + @_objcRuntimeName(_TtCC7Network14_NWProtocolTLS7Options) public class Options : NWProtocolOptions { /// Access the sec_protocol_options_t for a given network protocol /// options instance. See for functions @@ -36,6 +44,9 @@ public class NWProtocolTLS : NWProtocol { /// Access TLS metadata using NWConnection.metadata(protocolDefinition: NWProtocolTLS.definition) /// or in received ContentContext + // Set the ObjC name of this class to be nested in the customized ObjC + // name of NWNWProtocolTLSProtocolIP. + @_objcRuntimeName(_TtCC7Network14_NWProtocolTLS8Metadata) public class Metadata: NWProtocolMetadata { /// Access the sec_protocol_metadata_t for a given network protocol /// metadata instance. See for functions diff --git a/stdlib/public/Darwin/Network/NWProtocolUDP.swift b/stdlib/public/Darwin/Network/NWProtocolUDP.swift index fe77087e8d74c..7f345d79d9bd8 100644 --- a/stdlib/public/Darwin/Network/NWProtocolUDP.swift +++ b/stdlib/public/Darwin/Network/NWProtocolUDP.swift @@ -10,12 +10,20 @@ // //===----------------------------------------------------------------------===// +// NOTE: older overlays had Network.NWProtocolUDP as the ObjC name. +// The two must coexist, so it was renamed. The old name must not be +// used in the new runtime. _TtC7Network14_NWProtocolUDP is the +// mangled name for Network._NWProtocolUDP. +@_objcRuntimeName(_TtC7Network14_NWProtocolUDP) @available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *) public class NWProtocolUDP : NWProtocol { public static let definition: NWProtocolDefinition = { NWProtocolDefinition(nw_protocol_copy_udp_definition(), "udp") }() + // Set the ObjC name of this class to be nested in the customized ObjC + // name of NWProtocolUDP. + @_objcRuntimeName(_TtCC7Network14_NWProtocolUDP7Options) public class Options : NWProtocolOptions { private var _preferNoChecksum: Bool = false @@ -42,7 +50,10 @@ public class NWProtocolUDP : NWProtocol { } } - public class Metadata: NWProtocolMetadata { + // Set the ObjC name of this class to be nested in the customized ObjC + // name of NWProtocolUDP. + @_objcRuntimeName(_TtCC7Network14_NWProtocolUDP8Metadata) + public class Metadata: NWProtocolMetadata { override internal init(_ nw: nw_protocol_metadata_t) { super.init(nw) } diff --git a/stdlib/public/Darwin/SpriteKit/SpriteKit.swift b/stdlib/public/Darwin/SpriteKit/SpriteKit.swift index aa6fd22b47bd8..6b783677029b7 100644 --- a/stdlib/public/Darwin/SpriteKit/SpriteKit.swift +++ b/stdlib/public/Darwin/SpriteKit/SpriteKit.swift @@ -25,7 +25,7 @@ public typealias SKColor = UIColor // since that method only exists in a private header in SpriteKit, the lookup // mechanism by default fails to accept it as a valid AnyObject call // -// NOTE: older runtimes called this _SpriteKitMethodProvider. The two must +// NOTE: older overlays called this _SpriteKitMethodProvider. The two must // coexist, so it was renamed. The old name must not be used in the new // runtime. @objc class __SpriteKitMethodProvider : NSObject { diff --git a/stdlib/public/core/BridgingBuffer.swift b/stdlib/public/core/BridgingBuffer.swift index 34d0c3e356aeb..c3d0613fdeb35 100644 --- a/stdlib/public/core/BridgingBuffer.swift +++ b/stdlib/public/core/BridgingBuffer.swift @@ -15,7 +15,10 @@ internal struct _BridgingBufferHeader { internal var count: Int } -internal final class _BridgingBufferStorage +// NOTE: older runtimes called this class _BridgingBufferStorage. +// The two must coexist without a conflicting ObjC class name, so it +// was renamed. The old name must not be used in the new runtime. +internal final class __BridgingBufferStorage : ManagedBuffer<_BridgingBufferHeader, AnyObject> { } @@ -26,7 +29,7 @@ extension ManagedBufferPointer where Header == _BridgingBufferHeader, Element == AnyObject { internal init(_ count: Int) { self.init( - _uncheckedBufferClass: _BridgingBufferStorage.self, + _uncheckedBufferClass: __BridgingBufferStorage.self, minimumCapacity: count) self.withUnsafeMutablePointerToHeader { $0.initialize(to: Header(count)) diff --git a/stdlib/public/core/Dictionary.swift b/stdlib/public/core/Dictionary.swift index 9f0a733ffe5b3..b1b8bd16b5187 100644 --- a/stdlib/public/core/Dictionary.swift +++ b/stdlib/public/core/Dictionary.swift @@ -40,7 +40,7 @@ // / // | // V -// class _RawDictionaryStorage +// class __RawDictionaryStorage // +-----------------------------------------------------------+ // | | // | | @@ -62,7 +62,7 @@ // +----------------------------------------------+ // | enum Dictionary._Variant | // | +----------------------------------------+ | -// | | [ struct _CocoaDictionary | | +// | | [ struct __CocoaDictionary | | // | +---|------------------------------------+ | // +----/-----------------------------------------+ // / @@ -75,9 +75,9 @@ // +--------------+ // ^ // | -// \ struct _CocoaDictionary.Index +// \ struct __CocoaDictionary.Index // +--|------------------------------------+ -// | * base: _CocoaDictionary | +// | * base: __CocoaDictionary | // | allKeys: array of all keys | // | currentKeyIndex: index into allKeys | // +---------------------------------------+ @@ -87,8 +87,8 @@ // --------------------------- // // The native backing store is represented by three different classes: -// * `_RawDictionaryStorage` -// * `_EmptyDictionarySingleton` (extends Raw) +// * `__RawDictionaryStorage` +// * `__EmptyDictionarySingleton` (extends Raw) // * `_DictionaryStorage` (extends Raw) // // (Hereafter `Raw`, `Empty`, and `Storage`, respectively) @@ -401,7 +401,7 @@ public struct Dictionary { #if _runtime(_ObjC) @inlinable - internal init(_cocoa: __owned _CocoaDictionary) { + internal init(_cocoa: __owned __CocoaDictionary) { _variant = _Variant(cocoa: _cocoa) } @@ -422,7 +422,7 @@ public struct Dictionary { Dictionary can be backed by NSDictionary buffer only when both Key \ and Value are bridged verbatim to Objective-C """) - self.init(_cocoa: _CocoaDictionary(_immutableCocoaDictionary)) + self.init(_cocoa: __CocoaDictionary(_immutableCocoaDictionary)) } #endif @@ -1744,7 +1744,7 @@ extension Dictionary { internal enum _Variant { case native(_HashTable.Index) #if _runtime(_ObjC) - case cocoa(_CocoaDictionary.Index) + case cocoa(__CocoaDictionary.Index) #endif } @@ -1766,7 +1766,7 @@ extension Dictionary { #if _runtime(_ObjC) @inlinable @inline(__always) - internal init(_cocoa index: __owned _CocoaDictionary.Index) { + internal init(_cocoa index: __owned __CocoaDictionary.Index) { self.init(_variant: .cocoa(index)) } #endif @@ -1824,7 +1824,7 @@ extension Dictionary.Index { #if _runtime(_ObjC) @usableFromInline - internal var _asCocoa: _CocoaDictionary.Index { + internal var _asCocoa: __CocoaDictionary.Index { @_transparent get { switch _variant { @@ -1925,7 +1925,7 @@ extension Dictionary { internal enum _Variant { case native(_NativeDictionary.Iterator) #if _runtime(_ObjC) - case cocoa(_CocoaDictionary.Iterator) + case cocoa(__CocoaDictionary.Iterator) #endif } @@ -1944,7 +1944,7 @@ extension Dictionary { #if _runtime(_ObjC) @inlinable - internal init(_cocoa: __owned _CocoaDictionary.Iterator) { + internal init(_cocoa: __owned __CocoaDictionary.Iterator) { self.init(_variant: .cocoa(_cocoa)) } #endif @@ -1998,7 +1998,7 @@ extension Dictionary.Iterator { #if _runtime(_ObjC) @usableFromInline @_transparent - internal var _asCocoa: _CocoaDictionary.Iterator { + internal var _asCocoa: __CocoaDictionary.Iterator { get { switch _variant { case .native: diff --git a/stdlib/public/core/DictionaryBridging.swift b/stdlib/public/core/DictionaryBridging.swift index f22e00d78766f..23d753aa849ba 100644 --- a/stdlib/public/core/DictionaryBridging.swift +++ b/stdlib/public/core/DictionaryBridging.swift @@ -35,8 +35,8 @@ extension _NativeDictionary { // Bridging // Temporary var for SOME type safety. let nsDictionary: _NSDictionaryCore - if _storage === _RawDictionaryStorage.empty || count == 0 { - nsDictionary = _RawDictionaryStorage.empty + if _storage === __RawDictionaryStorage.empty || count == 0 { + nsDictionary = __RawDictionaryStorage.empty } else if _isBridgedVerbatimToObjectiveC(Key.self), _isBridgedVerbatimToObjectiveC(Value.self) { nsDictionary = unsafeDowncast( @@ -56,7 +56,7 @@ final internal class _SwiftDictionaryNSEnumerator : __SwiftNativeNSEnumerator, _NSEnumerator { @nonobjc internal var base: _NativeDictionary - @nonobjc internal var bridgedKeys: _BridgingHashBuffer? + @nonobjc internal var bridgedKeys: __BridgingHashBuffer? @nonobjc internal var nextBucket: _NativeDictionary.Bucket @nonobjc internal var endBucket: _NativeDictionary.Bucket @@ -186,41 +186,41 @@ final internal class _SwiftDeferredNSDictionary /// The buffer for bridged keys, if present. @nonobjc - private var _bridgedKeys: _BridgingHashBuffer? { + private var _bridgedKeys: __BridgingHashBuffer? { guard let ref = _stdlib_atomicLoadARCRef(object: _bridgedKeysPtr) else { return nil } - return unsafeDowncast(ref, to: _BridgingHashBuffer.self) + return unsafeDowncast(ref, to: __BridgingHashBuffer.self) } /// The buffer for bridged values, if present. @nonobjc - private var _bridgedValues: _BridgingHashBuffer? { + private var _bridgedValues: __BridgingHashBuffer? { guard let ref = _stdlib_atomicLoadARCRef(object: _bridgedValuesPtr) else { return nil } - return unsafeDowncast(ref, to: _BridgingHashBuffer.self) + return unsafeDowncast(ref, to: __BridgingHashBuffer.self) } /// Attach a buffer for bridged Dictionary keys. @nonobjc - private func _initializeBridgedKeys(_ storage: _BridgingHashBuffer) { + private func _initializeBridgedKeys(_ storage: __BridgingHashBuffer) { _stdlib_atomicInitializeARCRef(object: _bridgedKeysPtr, desired: storage) } /// Attach a buffer for bridged Dictionary values. @nonobjc - private func _initializeBridgedValues(_ storage: _BridgingHashBuffer) { + private func _initializeBridgedValues(_ storage: __BridgingHashBuffer) { _stdlib_atomicInitializeARCRef(object: _bridgedValuesPtr, desired: storage) } @nonobjc - internal func bridgeKeys() -> _BridgingHashBuffer? { + internal func bridgeKeys() -> __BridgingHashBuffer? { if _isBridgedVerbatimToObjectiveC(Key.self) { return nil } if let bridgedKeys = _bridgedKeys { return bridgedKeys } // Allocate and initialize heap storage for bridged keys. - let bridged = _BridgingHashBuffer.allocate( + let bridged = __BridgingHashBuffer.allocate( owner: native._storage, hashTable: native.hashTable) for bucket in native.hashTable { @@ -234,12 +234,12 @@ final internal class _SwiftDeferredNSDictionary } @nonobjc - internal func bridgeValues() -> _BridgingHashBuffer? { + internal func bridgeValues() -> __BridgingHashBuffer? { if _isBridgedVerbatimToObjectiveC(Value.self) { return nil } if let bridgedValues = _bridgedValues { return bridgedValues } // Allocate and initialize heap storage for bridged values. - let bridged = _BridgingHashBuffer.allocate( + let bridged = __BridgingHashBuffer.allocate( owner: native._storage, hashTable: native.hashTable) for bucket in native.hashTable { @@ -263,7 +263,7 @@ final internal class _SwiftDeferredNSDictionary @inline(__always) private func _key( at bucket: Bucket, - bridgedKeys: _BridgingHashBuffer? + bridgedKeys: __BridgingHashBuffer? ) -> AnyObject { if let bridgedKeys = bridgedKeys { return bridgedKeys[bucket] @@ -274,7 +274,7 @@ final internal class _SwiftDeferredNSDictionary @inline(__always) private func _value( at bucket: Bucket, - bridgedValues: _BridgingHashBuffer? + bridgedValues: __BridgingHashBuffer? ) -> AnyObject { if let bridgedValues = bridgedValues { return bridgedValues[bucket] @@ -417,9 +417,13 @@ final internal class _SwiftDeferredNSDictionary } } +// NOTE: older runtimes called this struct _CocoaDictionary. The two +// must coexist without conflicting ObjC class names from the nested +// classes, so it was renamed. The old names must not be used in the new +// runtime. @usableFromInline @_fixed_layout -internal struct _CocoaDictionary { +internal struct __CocoaDictionary { @usableFromInline internal let object: AnyObject @@ -429,14 +433,14 @@ internal struct _CocoaDictionary { } } -extension _CocoaDictionary { +extension __CocoaDictionary { @usableFromInline - internal func isEqual(to other: _CocoaDictionary) -> Bool { + internal func isEqual(to other: __CocoaDictionary) -> Bool { return _stdlib_NSObject_isEqual(self.object, other.object) } } -extension _CocoaDictionary: _DictionaryBuffer { +extension __CocoaDictionary: _DictionaryBuffer { @usableFromInline internal typealias Key = AnyObject @usableFromInline @@ -545,7 +549,7 @@ extension _CocoaDictionary: _DictionaryBuffer { } } -extension _CocoaDictionary { +extension __CocoaDictionary { @inlinable internal func mapValues( _ transform: (Value) throws -> T @@ -560,7 +564,7 @@ extension _CocoaDictionary { } } -extension _CocoaDictionary { +extension __CocoaDictionary { @_fixed_layout @usableFromInline internal struct Index { @@ -582,7 +586,7 @@ extension _CocoaDictionary { } } -extension _CocoaDictionary.Index { +extension __CocoaDictionary.Index { // FIXME(cocoa-index): Try using an NSEnumerator to speed this up. internal class Storage { // Assumption: we rely on NSDictionary.getObjects when being @@ -592,7 +596,7 @@ extension _CocoaDictionary.Index { /// A reference to the NSDictionary, which owns members in `allObjects`, /// or `allKeys`, for NSSet and NSDictionary respectively. - internal let base: _CocoaDictionary + internal let base: __CocoaDictionary // FIXME: swift-3-indexing-model: try to remove the cocoa reference, but // make sure that we have a safety check for accessing `allKeys`. Maybe // move both into the dictionary/set itself. @@ -601,7 +605,7 @@ extension _CocoaDictionary.Index { internal var allKeys: _BridgingBuffer internal init( - _ base: __owned _CocoaDictionary, + _ base: __owned __CocoaDictionary, _ allKeys: __owned _BridgingBuffer ) { self.base = base @@ -610,7 +614,7 @@ extension _CocoaDictionary.Index { } } -extension _CocoaDictionary.Index { +extension __CocoaDictionary.Index { @usableFromInline internal var handleBitPattern: UInt { @_effects(readonly) @@ -620,7 +624,7 @@ extension _CocoaDictionary.Index { } @usableFromInline - internal var dictionary: _CocoaDictionary { + internal var dictionary: __CocoaDictionary { @_effects(releasenone) get { return storage.base @@ -628,7 +632,7 @@ extension _CocoaDictionary.Index { } } -extension _CocoaDictionary.Index { +extension __CocoaDictionary.Index { @usableFromInline // FIXME(cocoa-index): Make inlinable @nonobjc internal var key: AnyObject { @@ -650,12 +654,12 @@ extension _CocoaDictionary.Index { } } -extension _CocoaDictionary.Index: Equatable { +extension __CocoaDictionary.Index: Equatable { @usableFromInline // FIXME(cocoa-index): Make inlinable @_effects(readonly) internal static func == ( - lhs: _CocoaDictionary.Index, - rhs: _CocoaDictionary.Index + lhs: __CocoaDictionary.Index, + rhs: __CocoaDictionary.Index ) -> Bool { _precondition(lhs.storage.base.object === rhs.storage.base.object, "Comparing indexes from different dictionaries") @@ -663,12 +667,12 @@ extension _CocoaDictionary.Index: Equatable { } } -extension _CocoaDictionary.Index: Comparable { +extension __CocoaDictionary.Index: Comparable { @usableFromInline // FIXME(cocoa-index): Make inlinable @_effects(readonly) internal static func < ( - lhs: _CocoaDictionary.Index, - rhs: _CocoaDictionary.Index + lhs: __CocoaDictionary.Index, + rhs: __CocoaDictionary.Index ) -> Bool { _precondition(lhs.storage.base.object === rhs.storage.base.object, "Comparing indexes from different dictionaries") @@ -676,7 +680,7 @@ extension _CocoaDictionary.Index: Comparable { } } -extension _CocoaDictionary: Sequence { +extension __CocoaDictionary: Sequence { @usableFromInline final internal class Iterator { // Cocoa Dictionary iterator has to be a class, otherwise we cannot @@ -692,7 +696,7 @@ extension _CocoaDictionary: Sequence { // `_fastEnumerationState`. There's code below relying on this. internal var _fastEnumerationStackBuf = _CocoaFastEnumerationStackBuf() - internal let base: _CocoaDictionary + internal let base: __CocoaDictionary internal var _fastEnumerationStatePtr: UnsafeMutablePointer<_SwiftNSFastEnumerationState> { @@ -713,7 +717,7 @@ extension _CocoaDictionary: Sequence { internal var itemIndex: Int = 0 internal var itemCount: Int = 0 - internal init(_ base: __owned _CocoaDictionary) { + internal init(_ base: __owned __CocoaDictionary) { self.base = base } } @@ -725,7 +729,7 @@ extension _CocoaDictionary: Sequence { } } -extension _CocoaDictionary.Iterator: IteratorProtocol { +extension __CocoaDictionary.Iterator: IteratorProtocol { @usableFromInline internal typealias Element = (key: AnyObject, value: AnyObject) @@ -796,7 +800,7 @@ extension Dictionary { return Dictionary(_native: _NativeDictionary(nativeStorage)) } - if s === _RawDictionaryStorage.empty { + if s === __RawDictionaryStorage.empty { return Dictionary() } diff --git a/stdlib/public/core/DictionaryStorage.swift b/stdlib/public/core/DictionaryStorage.swift index f3579af272693..39ac76578f126 100644 --- a/stdlib/public/core/DictionaryStorage.swift +++ b/stdlib/public/core/DictionaryStorage.swift @@ -16,10 +16,13 @@ import SwiftShims /// Enough bytes are allocated to hold the bitmap for marking valid entries, /// keys, and values. The data layout starts with the bitmap, followed by the /// keys, followed by the values. +// NOTE: older runtimes called this class _RawDictionaryStorage. The two +// must coexist without a conflicting ObjC class name, so it was +// renamed. The old name must not be used in the new runtime. @_fixed_layout @usableFromInline @_objc_non_lazy_realization -internal class _RawDictionaryStorage: __SwiftNativeNSDictionary { +internal class __RawDictionaryStorage: __SwiftNativeNSDictionary { // NOTE: The precise layout of this type is relied on in the runtime to // provide a statically allocated empty singleton. See // stdlib/public/stubs/GlobalObjects.cpp for details. @@ -109,9 +112,12 @@ internal class _RawDictionaryStorage: __SwiftNativeNSDictionary { /// The storage class for the singleton empty set. /// The single instance of this class is created by the runtime. +// NOTE: older runtimes called this class _EmptyDictionarySingleton. +// The two must coexist without a conflicting ObjC class name, so it was +// renamed. The old name must not be used in the new runtime. @_fixed_layout @usableFromInline -internal class _EmptyDictionarySingleton: _RawDictionaryStorage { +internal class __EmptyDictionarySingleton: __RawDictionaryStorage { @nonobjc internal override init(_doNotCallMe: ()) { _internalInvariantFailure("This class cannot be directly initialized") @@ -130,7 +136,7 @@ internal class _EmptyDictionarySingleton: _RawDictionaryStorage { } #if _runtime(_ObjC) -extension _EmptyDictionarySingleton: _NSDictionaryCore { +extension __EmptyDictionarySingleton: _NSDictionaryCore { @objc(copyWithZone:) internal func copy(with zone: _SwiftNSZone?) -> AnyObject { return self @@ -167,7 +173,7 @@ extension _EmptyDictionarySingleton: _NSDictionaryCore { @objc(keyEnumerator) internal func keyEnumerator() -> _NSEnumerator { - return _SwiftEmptyNSEnumerator() + return __SwiftEmptyNSEnumerator() } @objc(getObjects:andKeys:count:) @@ -180,13 +186,13 @@ extension _EmptyDictionarySingleton: _NSDictionaryCore { } #endif -extension _RawDictionaryStorage { +extension __RawDictionaryStorage { /// The empty singleton that is used for every single Dictionary that is /// created without any elements. The contents of the storage should never /// be mutated. @inlinable @nonobjc - internal static var empty: _EmptyDictionarySingleton { + internal static var empty: __EmptyDictionarySingleton { return Builtin.bridgeFromRawPointer( Builtin.addressof(&_swiftEmptyDictionarySingleton)) } @@ -194,7 +200,7 @@ extension _RawDictionaryStorage { @usableFromInline final internal class _DictionaryStorage - : _RawDictionaryStorage, _NSDictionaryCore { + : __RawDictionaryStorage, _NSDictionaryCore { // This type is made with allocWithTailElems, so no init is ever called. // But we still need to have an init to satisfy the compiler. @nonobjc @@ -359,7 +365,7 @@ extension _DictionaryStorage { @usableFromInline @_effects(releasenone) internal static func copy( - original: _RawDictionaryStorage + original: __RawDictionaryStorage ) -> _DictionaryStorage { return allocate( scale: original._scale, @@ -370,7 +376,7 @@ extension _DictionaryStorage { @usableFromInline @_effects(releasenone) static internal func resize( - original: _RawDictionaryStorage, + original: __RawDictionaryStorage, capacity: Int, move: Bool ) -> _DictionaryStorage { @@ -389,7 +395,7 @@ extension _DictionaryStorage { @usableFromInline @_effects(releasenone) static internal func convert( - _ cocoa: _CocoaDictionary, + _ cocoa: __CocoaDictionary, capacity: Int ) -> _DictionaryStorage { let scale = _HashTable.scale(forCapacity: capacity) diff --git a/stdlib/public/core/DictionaryVariant.swift b/stdlib/public/core/DictionaryVariant.swift index 3d9992dc4fa62..c091de0edb3dc 100644 --- a/stdlib/public/core/DictionaryVariant.swift +++ b/stdlib/public/core/DictionaryVariant.swift @@ -35,7 +35,7 @@ extension Dictionary { @_fixed_layout internal struct _Variant { @usableFromInline - internal var object: _BridgeStorage<_RawDictionaryStorage> + internal var object: _BridgeStorage<__RawDictionaryStorage> @inlinable @inline(__always) @@ -56,7 +56,7 @@ extension Dictionary { #if _runtime(_ObjC) @inlinable @inline(__always) - init(cocoa: __owned _CocoaDictionary) { + init(cocoa: __owned __CocoaDictionary) { self.object = _BridgeStorage(objC: cocoa.object) } #endif @@ -102,8 +102,8 @@ extension Dictionary._Variant { #if _runtime(_ObjC) @inlinable - internal var asCocoa: _CocoaDictionary { - return _CocoaDictionary(object.objCInstance) + internal var asCocoa: __CocoaDictionary { + return __CocoaDictionary(object.objCInstance) } #endif diff --git a/stdlib/public/core/Hashing.swift b/stdlib/public/core/Hashing.swift index 379e83b854c12..1429f5c99ae80 100644 --- a/stdlib/public/core/Hashing.swift +++ b/stdlib/public/core/Hashing.swift @@ -71,7 +71,10 @@ internal struct _UnmanagedAnyObjectArray { #if _runtime(_ObjC) /// An NSEnumerator implementation returning zero elements. This is useful when /// a concrete element type is not recoverable from the empty singleton. -final internal class _SwiftEmptyNSEnumerator +// NOTE: older runtimes called this class _SwiftEmptyNSEnumerator. The two +// must coexist without conflicting ObjC class names, so it was +// renamed. The old name must not be used in the new runtime. +final internal class __SwiftEmptyNSEnumerator : __SwiftNativeNSEnumerator, _NSEnumerator { internal override required init() {} @@ -107,8 +110,11 @@ final internal class _SwiftEmptyNSEnumerator /// /// Using a dedicated class for this rather than a _BridgingBuffer makes it easy /// to recognize these in heap dumps etc. -internal final class _BridgingHashBuffer - : ManagedBuffer<_BridgingHashBuffer.Header, AnyObject> { +// NOTE: older runtimes called this class _BridgingHashBuffer. +// The two must coexist without a conflicting ObjC class name, so it +// was renamed. The old name must not be used in the new runtime. +internal final class __BridgingHashBuffer + : ManagedBuffer<__BridgingHashBuffer.Header, AnyObject> { struct Header { internal var owner: AnyObject internal var hashTable: _HashTable @@ -122,11 +128,11 @@ internal final class _BridgingHashBuffer internal static func allocate( owner: AnyObject, hashTable: _HashTable - ) -> _BridgingHashBuffer { + ) -> __BridgingHashBuffer { let buffer = self.create(minimumCapacity: hashTable.bucketCount) { _ in Header(owner: owner, hashTable: hashTable) } - return unsafeDowncast(buffer, to: _BridgingHashBuffer.self) + return unsafeDowncast(buffer, to: __BridgingHashBuffer.self) } deinit { diff --git a/stdlib/public/core/NativeDictionary.swift b/stdlib/public/core/NativeDictionary.swift index f6abdaf2f3157..c475f33c0da25 100644 --- a/stdlib/public/core/NativeDictionary.swift +++ b/stdlib/public/core/NativeDictionary.swift @@ -10,7 +10,7 @@ // //===----------------------------------------------------------------------===// -/// A wrapper around _RawDictionaryStorage that provides most of the +/// A wrapper around __RawDictionaryStorage that provides most of the /// implementation of Dictionary. @usableFromInline @_fixed_layout @@ -18,20 +18,20 @@ internal struct _NativeDictionary { @usableFromInline internal typealias Element = (key: Key, value: Value) - /// See this comments on _RawDictionaryStorage and its subclasses to + /// See this comments on __RawDictionaryStorage and its subclasses to /// understand why we store an untyped storage here. @usableFromInline - internal var _storage: _RawDictionaryStorage + internal var _storage: __RawDictionaryStorage /// Constructs an instance from the empty singleton. @inlinable internal init() { - self._storage = _RawDictionaryStorage.empty + self._storage = __RawDictionaryStorage.empty } /// Constructs a dictionary adopting the given storage. @inlinable - internal init(_ storage: __owned _RawDictionaryStorage) { + internal init(_ storage: __owned __RawDictionaryStorage) { self._storage = storage } @@ -42,12 +42,12 @@ internal struct _NativeDictionary { #if _runtime(_ObjC) @inlinable - internal init(_ cocoa: __owned _CocoaDictionary) { + internal init(_ cocoa: __owned __CocoaDictionary) { self.init(cocoa, capacity: cocoa.count) } @inlinable - internal init(_ cocoa: __owned _CocoaDictionary, capacity: Int) { + internal init(_ cocoa: __owned __CocoaDictionary, capacity: Int) { _internalInvariant(cocoa.count <= capacity) self._storage = _DictionaryStorage.convert(cocoa, capacity: capacity) @@ -591,7 +591,7 @@ extension _NativeDictionary where Value: Equatable { #if _runtime(_ObjC) @inlinable - func isEqual(to other: _CocoaDictionary) -> Bool { + func isEqual(to other: __CocoaDictionary) -> Bool { if self.count != other.count { return false } defer { _fixLifetime(self) } diff --git a/stdlib/public/core/NativeSet.swift b/stdlib/public/core/NativeSet.swift index fa7a89ee45e0a..ec18aef26e321 100644 --- a/stdlib/public/core/NativeSet.swift +++ b/stdlib/public/core/NativeSet.swift @@ -10,27 +10,27 @@ // //===----------------------------------------------------------------------===// -/// A wrapper around _RawSetStorage that provides most of the +/// A wrapper around __RawSetStorage that provides most of the /// implementation of Set. @usableFromInline @_fixed_layout internal struct _NativeSet { - /// See the comments on _RawSetStorage and its subclasses to understand why we + /// See the comments on __RawSetStorage and its subclasses to understand why we /// store an untyped storage here. @usableFromInline - internal var _storage: _RawSetStorage + internal var _storage: __RawSetStorage /// Constructs an instance from the empty singleton. @inlinable @inline(__always) internal init() { - self._storage = _RawSetStorage.empty + self._storage = __RawSetStorage.empty } /// Constructs a native set adopting the given storage. @inlinable @inline(__always) - internal init(_ storage: __owned _RawSetStorage) { + internal init(_ storage: __owned __RawSetStorage) { self._storage = storage } @@ -41,12 +41,12 @@ internal struct _NativeSet { #if _runtime(_ObjC) @inlinable - internal init(_ cocoa: __owned _CocoaSet) { + internal init(_ cocoa: __owned __CocoaSet) { self.init(cocoa, capacity: cocoa.count) } @inlinable - internal init(_ cocoa: __owned _CocoaSet, capacity: Int) { + internal init(_ cocoa: __owned __CocoaSet, capacity: Int) { _internalInvariant(cocoa.count <= capacity) self._storage = _SetStorage.convert(cocoa, capacity: capacity) for element in cocoa { @@ -439,7 +439,7 @@ extension _NativeSet { #if _runtime(_ObjC) @inlinable - func isEqual(to other: _CocoaSet) -> Bool { + func isEqual(to other: __CocoaSet) -> Bool { if self.count != other.count { return false } defer { _fixLifetime(self) } diff --git a/stdlib/public/core/Set.swift b/stdlib/public/core/Set.swift index 4326bf85a85b9..33c3d0f73f460 100644 --- a/stdlib/public/core/Set.swift +++ b/stdlib/public/core/Set.swift @@ -174,7 +174,7 @@ public struct Set { #if _runtime(_ObjC) @inlinable - internal init(_cocoa: __owned _CocoaSet) { + internal init(_cocoa: __owned __CocoaSet) { _variant = _Variant(cocoa: _cocoa) } @@ -190,7 +190,7 @@ public struct Set { init(_immutableCocoaSet: __owned AnyObject) { _internalInvariant(_isBridgedVerbatimToObjectiveC(Element.self), "Set can be backed by NSSet _variant only when the member type can be bridged verbatim to Objective-C") - self.init(_cocoa: _CocoaSet(_immutableCocoaSet)) + self.init(_cocoa: __CocoaSet(_immutableCocoaSet)) } #endif } @@ -1279,7 +1279,7 @@ extension Set { internal enum _Variant { case native(_HashTable.Index) #if _runtime(_ObjC) - case cocoa(_CocoaSet.Index) + case cocoa(__CocoaSet.Index) #endif } @@ -1301,7 +1301,7 @@ extension Set { #if _runtime(_ObjC) @inlinable @inline(__always) - internal init(_cocoa index: __owned _CocoaSet.Index) { + internal init(_cocoa index: __owned __CocoaSet.Index) { self.init(_variant: .cocoa(index)) } #endif @@ -1362,7 +1362,7 @@ extension Set.Index { #if _runtime(_ObjC) @usableFromInline - internal var _asCocoa: _CocoaSet.Index { + internal var _asCocoa: __CocoaSet.Index { @_transparent get { switch _variant { @@ -1467,7 +1467,7 @@ extension Set { internal enum _Variant { case native(_NativeSet.Iterator) #if _runtime(_ObjC) - case cocoa(_CocoaSet.Iterator) + case cocoa(__CocoaSet.Iterator) #endif } @@ -1486,7 +1486,7 @@ extension Set { #if _runtime(_ObjC) @usableFromInline - internal init(_cocoa: __owned _CocoaSet.Iterator) { + internal init(_cocoa: __owned __CocoaSet.Iterator) { self.init(_variant: .cocoa(_cocoa)) } #endif @@ -1542,7 +1542,7 @@ extension Set.Iterator { #if _runtime(_ObjC) @usableFromInline @_transparent - internal var _asCocoa: _CocoaSet.Iterator { + internal var _asCocoa: __CocoaSet.Iterator { get { switch _variant { case .native: diff --git a/stdlib/public/core/SetBridging.swift b/stdlib/public/core/SetBridging.swift index 9c9d208129e96..bc84a5987b0f4 100644 --- a/stdlib/public/core/SetBridging.swift +++ b/stdlib/public/core/SetBridging.swift @@ -38,8 +38,8 @@ extension _NativeSet { // Bridging // Temporary var for SOME type safety. let nsSet: _NSSetCore - if _storage === _RawSetStorage.empty || count == 0 { - nsSet = _RawSetStorage.empty + if _storage === __RawSetStorage.empty || count == 0 { + nsSet = __RawSetStorage.empty } else if _isBridgedVerbatimToObjectiveC(Element.self) { nsSet = unsafeDowncast(_storage, to: _SetStorage.self) } else { @@ -59,7 +59,7 @@ final internal class _SwiftSetNSEnumerator : __SwiftNativeNSEnumerator, _NSEnumerator { @nonobjc internal var base: _NativeSet - @nonobjc internal var bridgedElements: _BridgingHashBuffer? + @nonobjc internal var bridgedElements: __BridgingHashBuffer? @nonobjc internal var nextBucket: _NativeSet.Bucket @nonobjc internal var endBucket: _NativeSet.Bucket @@ -172,27 +172,27 @@ final internal class _SwiftDeferredNSSet /// The buffer for bridged Set elements, if present. @nonobjc - private var _bridgedElements: _BridgingHashBuffer? { + private var _bridgedElements: __BridgingHashBuffer? { guard let ref = _stdlib_atomicLoadARCRef(object: _bridgedElementsPtr) else { return nil } - return unsafeDowncast(ref, to: _BridgingHashBuffer.self) + return unsafeDowncast(ref, to: __BridgingHashBuffer.self) } /// Attach a buffer for bridged Set elements. @nonobjc - private func _initializeBridgedElements(_ storage: _BridgingHashBuffer) { + private func _initializeBridgedElements(_ storage: __BridgingHashBuffer) { _stdlib_atomicInitializeARCRef( object: _bridgedElementsPtr, desired: storage) } @nonobjc - internal func bridgeElements() -> _BridgingHashBuffer { + internal func bridgeElements() -> __BridgingHashBuffer { if let bridgedElements = _bridgedElements { return bridgedElements } // Allocate and initialize heap storage for bridged objects. - let bridged = _BridgingHashBuffer.allocate( + let bridged = __BridgingHashBuffer.allocate( owner: native._storage, hashTable: native.hashTable) for bucket in native.hashTable { @@ -285,9 +285,13 @@ final internal class _SwiftDeferredNSSet } } +// NOTE: older overlays called this struct _CocoaSet. The two +// must coexist without conflicting ObjC class names from the nested +// classes, so it was renamed. The old names must not be used in the new +// runtime. @usableFromInline @_fixed_layout -internal struct _CocoaSet { +internal struct __CocoaSet { @usableFromInline internal let object: AnyObject @@ -297,7 +301,7 @@ internal struct _CocoaSet { } } -extension _CocoaSet { +extension __CocoaSet { @usableFromInline @_effects(releasenone) internal func member(for index: Index) -> AnyObject { @@ -311,14 +315,14 @@ extension _CocoaSet { } } -extension _CocoaSet { +extension __CocoaSet { @usableFromInline - internal func isEqual(to other: _CocoaSet) -> Bool { + internal func isEqual(to other: __CocoaSet) -> Bool { return _stdlib_NSObject_isEqual(self.object, other.object) } } -extension _CocoaSet: _SetBuffer { +extension __CocoaSet: _SetBuffer { @usableFromInline internal typealias Element = AnyObject @@ -404,7 +408,7 @@ extension _CocoaSet: _SetBuffer { } } -extension _CocoaSet { +extension __CocoaSet { @_fixed_layout @usableFromInline internal struct Index { @@ -426,7 +430,7 @@ extension _CocoaSet { } } -extension _CocoaSet.Index { +extension __CocoaSet.Index { // FIXME(cocoa-index): Try using an NSEnumerator to speed this up. internal class Storage { // Assumption: we rely on NSDictionary.getObjects when being @@ -436,7 +440,7 @@ extension _CocoaSet.Index { /// A reference to the NSSet, which owns members in `allObjects`, /// or `allKeys`, for NSSet and NSDictionary respectively. - internal let base: _CocoaSet + internal let base: __CocoaSet // FIXME: swift-3-indexing-model: try to remove the cocoa reference, but // make sure that we have a safety check for accessing `allKeys`. Maybe // move both into the dictionary/set itself. @@ -445,7 +449,7 @@ extension _CocoaSet.Index { internal var allKeys: _BridgingBuffer internal init( - _ base: __owned _CocoaSet, + _ base: __owned __CocoaSet, _ allKeys: __owned _BridgingBuffer ) { self.base = base @@ -454,7 +458,7 @@ extension _CocoaSet.Index { } } -extension _CocoaSet.Index { +extension __CocoaSet.Index { @usableFromInline internal var handleBitPattern: UInt { @_effects(readonly) @@ -464,7 +468,7 @@ extension _CocoaSet.Index { } } -extension _CocoaSet.Index { +extension __CocoaSet.Index { @usableFromInline // FIXME(cocoa-index): Make inlinable @nonobjc internal var element: AnyObject { @@ -486,27 +490,27 @@ extension _CocoaSet.Index { } } -extension _CocoaSet.Index: Equatable { +extension __CocoaSet.Index: Equatable { @usableFromInline // FIXME(cocoa-index): Make inlinable @_effects(readonly) - internal static func == (lhs: _CocoaSet.Index, rhs: _CocoaSet.Index) -> Bool { + internal static func == (lhs: __CocoaSet.Index, rhs: __CocoaSet.Index) -> Bool { _precondition(lhs.storage.base.object === rhs.storage.base.object, "Comparing indexes from different sets") return lhs._offset == rhs._offset } } -extension _CocoaSet.Index: Comparable { +extension __CocoaSet.Index: Comparable { @usableFromInline // FIXME(cocoa-index): Make inlinable @_effects(readonly) - internal static func < (lhs: _CocoaSet.Index, rhs: _CocoaSet.Index) -> Bool { + internal static func < (lhs: __CocoaSet.Index, rhs: __CocoaSet.Index) -> Bool { _precondition(lhs.storage.base.object === rhs.storage.base.object, "Comparing indexes from different sets") return lhs._offset < rhs._offset } } -extension _CocoaSet: Sequence { +extension __CocoaSet: Sequence { @usableFromInline final internal class Iterator { // Cocoa Set iterator has to be a class, otherwise we cannot @@ -522,7 +526,7 @@ extension _CocoaSet: Sequence { // `_fastEnumerationState`. There's code below relying on this. internal var _fastEnumerationStackBuf = _CocoaFastEnumerationStackBuf() - internal let base: _CocoaSet + internal let base: __CocoaSet internal var _fastEnumerationStatePtr: UnsafeMutablePointer<_SwiftNSFastEnumerationState> { @@ -543,7 +547,7 @@ extension _CocoaSet: Sequence { internal var itemIndex: Int = 0 internal var itemCount: Int = 0 - internal init(_ base: __owned _CocoaSet) { + internal init(_ base: __owned __CocoaSet) { self.base = base } } @@ -554,7 +558,7 @@ extension _CocoaSet: Sequence { } } -extension _CocoaSet.Iterator: IteratorProtocol { +extension __CocoaSet.Iterator: IteratorProtocol { @usableFromInline internal typealias Element = AnyObject @@ -618,7 +622,7 @@ extension Set { return Set(_native: _NativeSet(nativeStorage)) } - if s === _RawSetStorage.empty { + if s === __RawSetStorage.empty { return Set() } diff --git a/stdlib/public/core/SetStorage.swift b/stdlib/public/core/SetStorage.swift index f4a5086fb026f..44936c806e1c2 100644 --- a/stdlib/public/core/SetStorage.swift +++ b/stdlib/public/core/SetStorage.swift @@ -16,10 +16,13 @@ import SwiftShims /// Enough bytes are allocated to hold the bitmap for marking valid entries, /// keys, and values. The data layout starts with the bitmap, followed by the /// keys, followed by the values. +// NOTE: older runtimes called this class _RawSetStorage. The two +// must coexist without a conflicting ObjC class name, so it was +// renamed. The old name must not be used in the new runtime. @_fixed_layout @usableFromInline @_objc_non_lazy_realization -internal class _RawSetStorage: __SwiftNativeNSSet { +internal class __RawSetStorage: __SwiftNativeNSSet { // NOTE: The precise layout of this type is relied on in the runtime to // provide a statically allocated empty singleton. See // stdlib/public/stubs/GlobalObjects.cpp for details. @@ -104,9 +107,12 @@ internal class _RawSetStorage: __SwiftNativeNSSet { /// The storage class for the singleton empty set. /// The single instance of this class is created by the runtime. +// NOTE: older runtimes called this class _EmptySetSingleton. The two +// must coexist without conflicting ObjC class names, so it was renamed. +// The old names must not be used in the new runtime. @_fixed_layout @usableFromInline -internal class _EmptySetSingleton: _RawSetStorage { +internal class __EmptySetSingleton: __RawSetStorage { @nonobjc override internal init(_doNotCallMe: ()) { _internalInvariantFailure("This class cannot be directly initialized") @@ -120,18 +126,18 @@ internal class _EmptySetSingleton: _RawSetStorage { #endif } -extension _RawSetStorage { +extension __RawSetStorage { /// The empty singleton that is used for every single Set that is created /// without any elements. The contents of the storage must never be mutated. @inlinable @nonobjc - internal static var empty: _EmptySetSingleton { + internal static var empty: __EmptySetSingleton { return Builtin.bridgeFromRawPointer( Builtin.addressof(&_swiftEmptySetSingleton)) } } -extension _EmptySetSingleton: _NSSetCore { +extension __EmptySetSingleton: _NSSetCore { #if _runtime(_ObjC) // // NSSet implementation, assuming Self is the empty singleton @@ -153,7 +159,7 @@ extension _EmptySetSingleton: _NSSetCore { @objc internal func objectEnumerator() -> _NSEnumerator { - return _SwiftEmptyNSEnumerator() + return __SwiftEmptyNSEnumerator() } @objc(countByEnumeratingWithState:objects:count:) @@ -177,7 +183,7 @@ extension _EmptySetSingleton: _NSSetCore { @usableFromInline final internal class _SetStorage - : _RawSetStorage, _NSSetCore { + : __RawSetStorage, _NSSetCore { // This type is made with allocWithTailElems, so no init is ever called. // But we still need to have an init to satisfy the compiler. @nonobjc @@ -284,7 +290,7 @@ final internal class _SetStorage extension _SetStorage { @usableFromInline @_effects(releasenone) - internal static func copy(original: _RawSetStorage) -> _SetStorage { + internal static func copy(original: __RawSetStorage) -> _SetStorage { return .allocate( scale: original._scale, age: original._age, @@ -294,7 +300,7 @@ extension _SetStorage { @usableFromInline @_effects(releasenone) static internal func resize( - original: _RawSetStorage, + original: __RawSetStorage, capacity: Int, move: Bool ) -> _SetStorage { @@ -313,7 +319,7 @@ extension _SetStorage { @usableFromInline @_effects(releasenone) static internal func convert( - _ cocoa: _CocoaSet, + _ cocoa: __CocoaSet, capacity: Int ) -> _SetStorage { let scale = _HashTable.scale(forCapacity: capacity) diff --git a/stdlib/public/core/SetVariant.swift b/stdlib/public/core/SetVariant.swift index 24e4e50aab168..355b518842dd3 100644 --- a/stdlib/public/core/SetVariant.swift +++ b/stdlib/public/core/SetVariant.swift @@ -31,7 +31,7 @@ extension Set { @_fixed_layout internal struct _Variant { @usableFromInline - internal var object: _BridgeStorage<_RawSetStorage> + internal var object: _BridgeStorage<__RawSetStorage> @inlinable @inline(__always) @@ -52,7 +52,7 @@ extension Set { #if _runtime(_ObjC) @inlinable @inline(__always) - init(cocoa: __owned _CocoaSet) { + init(cocoa: __owned __CocoaSet) { self.object = _BridgeStorage(objC: cocoa.object) } #endif @@ -103,8 +103,8 @@ extension Set._Variant { #if _runtime(_ObjC) @inlinable - internal var asCocoa: _CocoaSet { - return _CocoaSet(object.objCInstance) + internal var asCocoa: __CocoaSet { + return __CocoaSet(object.objCInstance) } #endif @@ -318,7 +318,7 @@ extension Set._Variant { #if _runtime(_ObjC) @inlinable internal mutating func _migrateToNative( - _ cocoa: _CocoaSet, + _ cocoa: __CocoaSet, removing member: Element ) -> Element { // FIXME(performance): fuse data migration and element deletion into one diff --git a/stdlib/public/core/StringBridge.swift b/stdlib/public/core/StringBridge.swift index 1fc25c233d6a1..21b7cb9ebf4c4 100644 --- a/stdlib/public/core/StringBridge.swift +++ b/stdlib/public/core/StringBridge.swift @@ -149,9 +149,9 @@ internal enum _KnownCocoaString { #endif switch _unsafeAddressOfCocoaStringClass(str) { - case unsafeBitCast(_StringStorage.self, to: UInt.self): + case unsafeBitCast(__StringStorage.self, to: UInt.self): self = .storage - case unsafeBitCast(_SharedStringStorage.self, to: UInt.self): + case unsafeBitCast(__SharedStringStorage.self, to: UInt.self): self = .shared default: self = .cocoa @@ -216,10 +216,10 @@ internal func _bridgeCocoaString(_ cocoaString: _CocoaString) -> _StringGuts { switch _KnownCocoaString(cocoaString) { case .storage: return _unsafeUncheckedDowncast( - cocoaString, to: _StringStorage.self).asString._guts + cocoaString, to: __StringStorage.self).asString._guts case .shared: return _unsafeUncheckedDowncast( - cocoaString, to: _SharedStringStorage.self).asString._guts + cocoaString, to: __SharedStringStorage.self).asString._guts #if !(arch(i386) || arch(arm)) case .tagged: return _StringGuts(_SmallString(taggedCocoa: cocoaString)) @@ -284,7 +284,7 @@ extension String { // TODO: We'd rather emit a valid ObjC object statically than create a // shared string class instance. let gutsCountAndFlags = _guts._object._countAndFlags - return _SharedStringStorage( + return __SharedStringStorage( immortal: _guts._object.fastUTF8.baseAddress!, countAndFlags: _StringObject.CountAndFlags( sharedCount: _guts.count, isASCII: gutsCountAndFlags.isASCII)) diff --git a/stdlib/public/core/StringCreate.swift b/stdlib/public/core/StringCreate.swift index ec032c1d0fb02..262f0eeca7b7c 100644 --- a/stdlib/public/core/StringCreate.swift +++ b/stdlib/public/core/StringCreate.swift @@ -38,7 +38,7 @@ extension String { return String(_StringGuts(smol)) } - let storage = _StringStorage.create(initializingFrom: input, isASCII: true) + let storage = __StringStorage.create(initializingFrom: input, isASCII: true) return storage.asString } @@ -83,7 +83,7 @@ extension String { return String(_StringGuts(smol)) } - let storage = _StringStorage.create( + let storage = __StringStorage.create( initializingFrom: input, isASCII: isASCII) return storage.asString } @@ -98,7 +98,7 @@ extension String { } let isASCII = asciiPreScanResult - let storage = _StringStorage.create( + let storage = __StringStorage.create( initializingFrom: input, isASCII: isASCII) return storage.asString } diff --git a/stdlib/public/core/StringGuts.swift b/stdlib/public/core/StringGuts.swift index 03aeb0679466d..f90a886267a10 100644 --- a/stdlib/public/core/StringGuts.swift +++ b/stdlib/public/core/StringGuts.swift @@ -56,11 +56,11 @@ extension _StringGuts { } @inline(__always) - internal init(_ storage: _StringStorage) { + internal init(_ storage: __StringStorage) { self.init(_StringObject(storage)) } - internal init(_ storage: _SharedStringStorage) { + internal init(_ storage: __SharedStringStorage) { self.init(_StringObject(storage)) } diff --git a/stdlib/public/core/StringGutsRangeReplaceable.swift b/stdlib/public/core/StringGutsRangeReplaceable.swift index f1c918d99f274..fc27b12377068 100644 --- a/stdlib/public/core/StringGutsRangeReplaceable.swift +++ b/stdlib/public/core/StringGutsRangeReplaceable.swift @@ -84,7 +84,7 @@ extension _StringGuts { if _fastPath(isFastUTF8) { let isASCII = self.isASCII let storage = self.withFastUTF8 { - _StringStorage.create( + __StringStorage.create( initializingFrom: $0, capacity: growthTarget, isASCII: isASCII) } @@ -101,7 +101,7 @@ extension _StringGuts { // into a StringStorage space. let selfUTF8 = Array(String(self).utf8) selfUTF8.withUnsafeBufferPointer { - self = _StringGuts(_StringStorage.create( + self = _StringGuts(__StringStorage.create( initializingFrom: $0, capacity: n, isASCII: self.isASCII)) } } diff --git a/stdlib/public/core/StringObject.swift b/stdlib/public/core/StringObject.swift index 49b94f36af184..5bc877f37b7c7 100644 --- a/stdlib/public/core/StringObject.swift +++ b/stdlib/public/core/StringObject.swift @@ -838,13 +838,13 @@ extension _StringObject { } } - internal var nativeStorage: _StringStorage { + internal var nativeStorage: __StringStorage { @inline(__always) get { #if arch(i386) || arch(arm) guard case .native(let storage) = _variant else { _internalInvariantFailure() } - return _unsafeUncheckedDowncast(storage, to: _StringStorage.self) + return _unsafeUncheckedDowncast(storage, to: __StringStorage.self) #else _internalInvariant(hasNativeStorage) return Builtin.reinterpretCast(largeAddressBits) @@ -852,13 +852,13 @@ extension _StringObject { } } - internal var sharedStorage: _SharedStringStorage { + internal var sharedStorage: __SharedStringStorage { @inline(__always) get { #if arch(i386) || arch(arm) guard case .native(let storage) = _variant else { _internalInvariantFailure() } - return _unsafeUncheckedDowncast(storage, to: _SharedStringStorage.self) + return _unsafeUncheckedDowncast(storage, to: __SharedStringStorage.self) #else _internalInvariant(largeFastIsShared && !largeIsCocoa) _internalInvariant(hasSharedStorage) @@ -982,7 +982,7 @@ extension _StringObject { } @inline(__always) - internal init(_ storage: _StringStorage) { + internal init(_ storage: __StringStorage) { #if arch(i386) || arch(arm) self.init( variant: .native(storage), @@ -996,7 +996,7 @@ extension _StringObject { #endif } - internal init(_ storage: _SharedStringStorage) { + internal init(_ storage: __SharedStringStorage) { #if arch(i386) || arch(arm) self.init( variant: .native(storage), @@ -1100,7 +1100,7 @@ extension _StringObject { } if _countAndFlags.isNativelyStored { let anyObj = Builtin.reinterpretCast(largeAddressBits) as AnyObject - _internalInvariant(anyObj is _StringStorage) + _internalInvariant(anyObj is __StringStorage) } } diff --git a/stdlib/public/core/StringStorage.swift b/stdlib/public/core/StringStorage.swift index 260d958022039..d6f26946c3ab1 100644 --- a/stdlib/public/core/StringStorage.swift +++ b/stdlib/public/core/StringStorage.swift @@ -126,10 +126,10 @@ extension _AbstractStringStorage { switch knownOther { case .storage: return _nativeIsEqual( - _unsafeUncheckedDowncast(other, to: _StringStorage.self)) + _unsafeUncheckedDowncast(other, to: __StringStorage.self)) case .shared: return _nativeIsEqual( - _unsafeUncheckedDowncast(other, to: _SharedStringStorage.self)) + _unsafeUncheckedDowncast(other, to: __SharedStringStorage.self)) #if !(arch(i386) || arch(arm)) case .tagged: fallthrough @@ -172,7 +172,10 @@ private typealias CountAndFlags = _StringObject.CountAndFlags // Optional<_StringBreadcrumbs>. // -final internal class _StringStorage +// NOTE: older runtimes called this class _StringStorage. The two +// must coexist without conflicting ObjC class names, so it was +// renamed. The old name must not be used in the new runtime. +final internal class __StringStorage : __SwiftNativeNSString, _AbstractStringStorage { #if arch(i386) || arch(arm) // The total allocated storage capacity. Note that this includes the required @@ -299,7 +302,7 @@ final internal class _StringStorage @objc(copyWithZone:) final internal func copy(with zone: _SwiftNSZone?) -> AnyObject { - // While _StringStorage instances aren't immutable in general, + // While __StringStorage instances aren't immutable in general, // mutations may only occur when instances are uniquely referenced. // Therefore, it is safe to return self here; any outstanding Objective-C // reference will make the instance non-unique. @@ -350,13 +353,13 @@ private func determineCodeUnitCapacity(_ desiredCapacity: Int) -> Int { } // Creation -extension _StringStorage { +extension __StringStorage { @_effects(releasenone) private static func create( realCodeUnitCapacity: Int, countAndFlags: CountAndFlags - ) -> _StringStorage { + ) -> __StringStorage { let storage = Builtin.allocWithTailElems_2( - _StringStorage.self, + __StringStorage.self, realCodeUnitCapacity._builtinWordValue, UInt8.self, 1._builtinWordValue, Optional<_StringBreadcrumbs>.self) #if arch(i386) || arch(arm) @@ -380,12 +383,12 @@ extension _StringStorage { @_effects(releasenone) private static func create( capacity: Int, countAndFlags: CountAndFlags - ) -> _StringStorage { + ) -> __StringStorage { _internalInvariant(capacity >= countAndFlags.count) let realCapacity = determineCodeUnitCapacity(capacity) _internalInvariant(realCapacity > capacity) - return _StringStorage.create( + return __StringStorage.create( realCodeUnitCapacity: realCapacity, countAndFlags: countAndFlags) } @@ -394,11 +397,11 @@ extension _StringStorage { initializingFrom bufPtr: UnsafeBufferPointer, capacity: Int, isASCII: Bool - ) -> _StringStorage { + ) -> __StringStorage { let countAndFlags = CountAndFlags( mortalCount: bufPtr.count, isASCII: isASCII) _internalInvariant(capacity >= bufPtr.count) - let storage = _StringStorage.create( + let storage = __StringStorage.create( capacity: capacity, countAndFlags: countAndFlags) let addr = bufPtr.baseAddress._unsafelyUnwrappedUnchecked storage.mutableStart.initialize(from: addr, count: bufPtr.count) @@ -409,14 +412,14 @@ extension _StringStorage { @_effects(releasenone) internal static func create( initializingFrom bufPtr: UnsafeBufferPointer, isASCII: Bool - ) -> _StringStorage { - return _StringStorage.create( + ) -> __StringStorage { + return __StringStorage.create( initializingFrom: bufPtr, capacity: bufPtr.count, isASCII: isASCII) } } // Usage -extension _StringStorage { +extension __StringStorage { @inline(__always) private var mutableStart: UnsafeMutablePointer { return UnsafeMutablePointer(Builtin.projectTailElems(self, UInt8.self)) @@ -504,7 +507,7 @@ extension _StringStorage { } // Appending -extension _StringStorage { +extension __StringStorage { // Perform common post-RRC adjustments and invariant enforcement. @_effects(releasenone) private func _postRRCAdjust(newCount: Int, newIsASCII: Bool) { @@ -564,7 +567,7 @@ extension _StringStorage { } // Removing -extension _StringStorage { +extension __StringStorage { @_effects(releasenone) internal func remove(from lower: Int, to upper: Int) { _internalInvariant(lower <= upper) @@ -646,7 +649,10 @@ extension _StringStorage { } // For shared storage and bridging literals -final internal class _SharedStringStorage +// NOTE: older runtimes called this class _SharedStringStorage. The two +// must coexist without conflicting ObjC class names, so it was +// renamed. The old name must not be used in the new runtime. +final internal class __SharedStringStorage : __SwiftNativeNSString, _AbstractStringStorage { internal var _owner: AnyObject? internal var start: UnsafePointer @@ -775,7 +781,7 @@ final internal class _SharedStringStorage @objc(copyWithZone:) final internal func copy(with zone: _SwiftNSZone?) -> AnyObject { - // While _StringStorage instances aren't immutable in general, + // While __StringStorage instances aren't immutable in general, // mutations may only occur when instances are uniquely referenced. // Therefore, it is safe to return self here; any outstanding Objective-C // reference will make the instance non-unique. @@ -786,7 +792,7 @@ final internal class _SharedStringStorage } -extension _SharedStringStorage { +extension __SharedStringStorage { #if !INTERNAL_CHECKS_ENABLED @inline(__always) internal func _invariantCheck() {} diff --git a/stdlib/public/core/SwiftNativeNSArray.swift b/stdlib/public/core/SwiftNativeNSArray.swift index f6a6d1efc2bab..1c18175976116 100644 --- a/stdlib/public/core/SwiftNativeNSArray.swift +++ b/stdlib/public/core/SwiftNativeNSArray.swift @@ -160,10 +160,10 @@ extension __SwiftNativeNSArrayWithContiguousStorage : _NSArrayCore { to: Optional.self) } - internal var _heapBufferBridged: _BridgingBufferStorage? { + internal var _heapBufferBridged: __BridgingBufferStorage? { if let ref = _stdlib_atomicLoadARCRef(object: _heapBufferBridgedPtr) { - return unsafeBitCast(ref, to: _BridgingBufferStorage.self) + return unsafeBitCast(ref, to: __BridgingBufferStorage.self) } return nil } @@ -174,7 +174,7 @@ extension __SwiftNativeNSArrayWithContiguousStorage : _NSArrayCore { self._nativeStorage = _nativeStorage } - internal func _destroyBridgedStorage(_ hb: _BridgingBufferStorage?) { + internal func _destroyBridgedStorage(_ hb: __BridgingBufferStorage?) { if let bridgedStorage = hb { let buffer = _BridgingBuffer(bridgedStorage) let count = buffer.count @@ -216,7 +216,7 @@ extension __SwiftNativeNSArrayWithContiguousStorage : _NSArrayCore { // Another thread won the race. Throw out our buffer. _destroyBridgedStorage( - unsafeDowncast(objects.storage!, to: _BridgingBufferStorage.self)) + unsafeDowncast(objects.storage!, to: __BridgingBufferStorage.self)) } continue // Try again } diff --git a/stdlib/public/runtime/Metadata.cpp b/stdlib/public/runtime/Metadata.cpp index 8e7287eb92aa6..6e3f00a78b69e 100644 --- a/stdlib/public/runtime/Metadata.cpp +++ b/stdlib/public/runtime/Metadata.cpp @@ -2204,9 +2204,24 @@ static void initGenericClassObjCName(ClassMetadata *theClass) { auto string = Demangle::mangleNodeOld(globalNode); - auto fullNameBuf = (char*)swift_slowAlloc(string.size() + 1, 0); + // If the class is in the Swift module, add a $ to the end of the ObjC + // name. The old and new Swift libraries must be able to coexist in + // the same process, and this avoids warnings due to the ObjC names + // colliding. + bool addSuffix = strncmp(string.c_str(), "_TtGCs", 6) == 0; + + size_t allocationSize = string.size() + 1; + if (addSuffix) + allocationSize += 1; + + auto fullNameBuf = (char*)swift_slowAlloc(allocationSize, 0); memcpy(fullNameBuf, string.c_str(), string.size() + 1); + if (addSuffix) { + fullNameBuf[string.size()] = '$'; + fullNameBuf[string.size() + 1] = '\0'; + } + auto theMetaclass = (ClassMetadata *)object_getClass((id)theClass); getROData(theClass)->Name = fullNameBuf; diff --git a/stdlib/public/stubs/GlobalObjects.cpp b/stdlib/public/stubs/GlobalObjects.cpp index aeed5ae6ed721..a59c3c1a602e7 100644 --- a/stdlib/public/stubs/GlobalObjects.cpp +++ b/stdlib/public/stubs/GlobalObjects.cpp @@ -28,13 +28,13 @@ namespace swift { SWIFT_RUNTIME_STDLIB_API ClassMetadata CLASS_METADATA_SYM(s19__EmptyArrayStorage); -// _direct type metadata for Swift._EmptyDictionarySingleton +// _direct type metadata for Swift.__EmptyDictionarySingleton SWIFT_RUNTIME_STDLIB_API -ClassMetadata CLASS_METADATA_SYM(s25_EmptyDictionarySingleton); +ClassMetadata CLASS_METADATA_SYM(s26__EmptyDictionarySingleton); -// _direct type metadata for Swift._EmptySetSingleton +// _direct type metadata for Swift.__EmptySetSingleton SWIFT_RUNTIME_STDLIB_API -ClassMetadata CLASS_METADATA_SYM(s18_EmptySetSingleton); +ClassMetadata CLASS_METADATA_SYM(s19__EmptySetSingleton); } // namespace swift SWIFT_RUNTIME_STDLIB_API @@ -55,7 +55,7 @@ SWIFT_RUNTIME_STDLIB_API swift::_SwiftEmptyDictionarySingleton swift::_swiftEmptyDictionarySingleton = { // HeapObject header; { - &swift::CLASS_METADATA_SYM(s25_EmptyDictionarySingleton), // isa pointer + &swift::CLASS_METADATA_SYM(s26__EmptyDictionarySingleton), // isa pointer }, // _SwiftDictionaryBodyStorage body; @@ -82,7 +82,7 @@ SWIFT_RUNTIME_STDLIB_API swift::_SwiftEmptySetSingleton swift::_swiftEmptySetSingleton = { // HeapObject header; { - &swift::CLASS_METADATA_SYM(s18_EmptySetSingleton), // isa pointer + &swift::CLASS_METADATA_SYM(s19__EmptySetSingleton), // isa pointer }, // _SwiftSetBodyStorage body; diff --git a/test/api-digester/Outputs/stability-stdlib-abi.swift.expected b/test/api-digester/Outputs/stability-stdlib-abi.swift.expected index e6df12d462047..f8a2ab1e4ffc3 100644 --- a/test/api-digester/Outputs/stability-stdlib-abi.swift.expected +++ b/test/api-digester/Outputs/stability-stdlib-abi.swift.expected @@ -28,3 +28,46 @@ Var _StringObject.objCBridgeableObject has been removed Var _StringObject._countAndFlags is no longer a stored property Var _StringObject._countAndFlagsBits is added to a non-resilient type + +Class _DictionaryStorage has changed its super class from _RawDictionaryStorage to __RawDictionaryStorage +Class _EmptyDictionarySingleton has been renamed to Class __EmptyDictionarySingleton +Class _EmptyDictionarySingleton has changed its super class from _RawDictionaryStorage to __RawDictionaryStorage +Class _EmptySetSingleton has been renamed to Class __EmptySetSingleton +Class _EmptySetSingleton has changed its super class from _RawSetStorage to __RawSetStorage +Class _RawDictionaryStorage has been renamed to Class __RawDictionaryStorage +Class _RawSetStorage has been renamed to Class __RawSetStorage +Class _SetStorage has changed its super class from _RawSetStorage to __RawSetStorage +Constructor Dictionary._Variant.init(cocoa:) has parameter 0 type change from _CocoaDictionary to __CocoaDictionary +Constructor Dictionary.init(_cocoa:) has parameter 0 type change from _CocoaDictionary to __CocoaDictionary +Constructor Set._Variant.init(cocoa:) has parameter 0 type change from _CocoaSet to __CocoaSet +Constructor Set.init(_cocoa:) has parameter 0 type change from _CocoaSet to __CocoaSet +Constructor _CocoaDictionary.init(_:) has return type change from _CocoaDictionary to __CocoaDictionary +Constructor _CocoaSet.init(_:) has return type change from _CocoaSet to __CocoaSet +Constructor _NativeDictionary.init(_:) has parameter 0 type change from _CocoaDictionary to __CocoaDictionary +Constructor _NativeDictionary.init(_:) has parameter 0 type change from _RawDictionaryStorage to __RawDictionaryStorage +Constructor _NativeDictionary.init(_:capacity:) has parameter 0 type change from _CocoaDictionary to __CocoaDictionary +Constructor _NativeSet.init(_:) has parameter 0 type change from _CocoaSet to __CocoaSet +Constructor _NativeSet.init(_:) has parameter 0 type change from _RawSetStorage to __RawSetStorage +Constructor _NativeSet.init(_:capacity:) has parameter 0 type change from _CocoaSet to __CocoaSet +Func Set._Variant._migrateToNative(_:removing:) has parameter 0 type change from _CocoaSet to __CocoaSet +Func _CocoaDictionary.isEqual(to:) has parameter 0 type change from _CocoaDictionary to __CocoaDictionary +Func _CocoaSet.isEqual(to:) has parameter 0 type change from _CocoaSet to __CocoaSet +Func _DictionaryStorage.convert(_:capacity:) has parameter 0 type change from _CocoaDictionary to __CocoaDictionary +Func _DictionaryStorage.copy(original:) has parameter 0 type change from _RawDictionaryStorage to __RawDictionaryStorage +Func _DictionaryStorage.resize(original:capacity:move:) has parameter 0 type change from _RawDictionaryStorage to __RawDictionaryStorage +Func _NativeDictionary.isEqual(to:) has parameter 0 type change from _CocoaDictionary to __CocoaDictionary +Func _NativeSet.isEqual(to:) has parameter 0 type change from _CocoaSet to __CocoaSet +Func _SetStorage.convert(_:capacity:) has parameter 0 type change from _CocoaSet to __CocoaSet +Func _SetStorage.copy(original:) has parameter 0 type change from _RawSetStorage to __RawSetStorage +Func _SetStorage.resize(original:capacity:move:) has parameter 0 type change from _RawSetStorage to __RawSetStorage +Struct _CocoaDictionary has been renamed to Struct __CocoaDictionary +Struct _CocoaSet has been renamed to Struct __CocoaSet +Var Dictionary._Variant.asCocoa has declared type change from _CocoaDictionary to __CocoaDictionary +Var Dictionary._Variant.object has declared type change from _BridgeStorage<_RawDictionaryStorage> to _BridgeStorage<__RawDictionaryStorage> +Var Set._Variant.asCocoa has declared type change from _CocoaSet to __CocoaSet +Var Set._Variant.object has declared type change from _BridgeStorage<_RawSetStorage> to _BridgeStorage<__RawSetStorage> +Var _CocoaDictionary.Index.dictionary has declared type change from _CocoaDictionary to __CocoaDictionary +Var _NativeDictionary._storage has declared type change from _RawDictionaryStorage to __RawDictionaryStorage +Var _NativeSet._storage has declared type change from _RawSetStorage to __RawSetStorage +Var _RawDictionaryStorage.empty has declared type change from _EmptyDictionarySingleton to __EmptyDictionarySingleton +Var _RawSetStorage.empty has declared type change from _EmptySetSingleton to __EmptySetSingleton diff --git a/test/stdlib/Inputs/DictionaryKeyValueTypesObjC.swift b/test/stdlib/Inputs/DictionaryKeyValueTypesObjC.swift index 35e87fda6d3c5..d367e899e231c 100644 --- a/test/stdlib/Inputs/DictionaryKeyValueTypesObjC.swift +++ b/test/stdlib/Inputs/DictionaryKeyValueTypesObjC.swift @@ -33,7 +33,7 @@ func isNativeNSDictionary(_ d: NSDictionary) -> Bool { let className: NSString = NSStringFromClass(type(of: d)) as NSString return [ "_SwiftDeferredNSDictionary", - "_EmptyDictionarySingleton", + "__EmptyDictionarySingleton", "_DictionaryStorage"].contains { className.range(of: $0).length > 0 }