[Stdlib] Silence all warnings about deprecated @objc inference.

This eliminates 26 Objective-C entry points that we never intended to expose, but that came “for free” with the @objc inference rules.
This commit is contained in:
Doug Gregor
2017-03-28 17:16:29 -07:00
parent 79440cd7f4
commit cc225eb9fa
5 changed files with 41 additions and 8 deletions

View File

@@ -25,6 +25,7 @@ internal final class _EmptyArrayStorage
@_inlineable @_inlineable
@_versioned @_versioned
@nonobjc
init(_doNotCallMe: ()) { init(_doNotCallMe: ()) {
_sanityCheckFailure("creating instance of _EmptyArrayStorage") _sanityCheckFailure("creating instance of _EmptyArrayStorage")
} }
@@ -40,6 +41,7 @@ internal final class _EmptyArrayStorage
@_inlineable @_inlineable
@_versioned @_versioned
@nonobjc
override func _getNonVerbatimBridgedCount() -> Int { override func _getNonVerbatimBridgedCount() -> Int {
return 0 return 0
} }
@@ -121,6 +123,7 @@ final class _ContiguousArrayStorage<Element> : _ContiguousArrayStorageBase {
/// - Precondition: `Element` is bridged non-verbatim. /// - Precondition: `Element` is bridged non-verbatim.
@_inlineable @_inlineable
@_versioned @_versioned
@nonobjc
override internal func _getNonVerbatimBridgedCount() -> Int { override internal func _getNonVerbatimBridgedCount() -> Int {
_sanityCheck( _sanityCheck(
!_isBridgedVerbatimToObjectiveC(Element.self), !_isBridgedVerbatimToObjectiveC(Element.self),

View File

@@ -2495,17 +2495,23 @@ internal class _RawNative${Self}Storage:
_SwiftNativeNS${Self}, _NS${Self}Core _SwiftNativeNS${Self}, _NS${Self}Core
{ {
internal typealias RawStorage = _RawNative${Self}Storage internal typealias RawStorage = _RawNative${Self}Storage
@nonobjc
internal final var capacity: Int internal final var capacity: Int
internal final var count: Int internal final var count: Int
internal final var initializedEntries: _UnsafeBitMap internal final var initializedEntries: _UnsafeBitMap
@nonobjc
internal final var keys: UnsafeMutableRawPointer internal final var keys: UnsafeMutableRawPointer
% if Self == 'Dictionary': % if Self == 'Dictionary':
@nonobjc
internal final var values: UnsafeMutableRawPointer internal final var values: UnsafeMutableRawPointer
% end % end
// This API is unsafe and needs a `_fixLifetime` in the caller. // This API is unsafe and needs a `_fixLifetime` in the caller.
@nonobjc
internal final internal final
var _initializedHashtableEntriesBitMapBuffer: UnsafeMutablePointer<UInt> { var _initializedHashtableEntriesBitMapBuffer: UnsafeMutablePointer<UInt> {
return UnsafeMutablePointer(Builtin.projectTailElems(self, UInt.self)) return UnsafeMutablePointer(Builtin.projectTailElems(self, UInt.self))
@@ -2514,6 +2520,7 @@ internal class _RawNative${Self}Storage:
/// The empty singleton that is used for every single Dictionary that is /// The empty singleton that is used for every single Dictionary that is
/// created without any elements. The contents of the storage should never /// created without any elements. The contents of the storage should never
/// be mutated. /// be mutated.
@nonobjc
internal static var empty: RawStorage { internal static var empty: RawStorage {
return Builtin.bridgeFromRawPointer( return Builtin.bridgeFromRawPointer(
Builtin.addressof(&_swiftEmpty${Self}Storage)) Builtin.addressof(&_swiftEmpty${Self}Storage))
@@ -2521,6 +2528,7 @@ internal class _RawNative${Self}Storage:
// This type is made with allocWithTailElems, so no init is ever called. // This type is made with allocWithTailElems, so no init is ever called.
// But we still need to have an init to satisfy the compiler. // But we still need to have an init to satisfy the compiler.
@nonobjc
internal init(_doNotCallMe: ()) { internal init(_doNotCallMe: ()) {
_sanityCheckFailure("Only create this by using the `empty` singleton") _sanityCheckFailure("Only create this by using the `empty` singleton")
} }
@@ -2533,6 +2541,7 @@ internal class _RawNative${Self}Storage:
/// Get the NSEnumerator implementation for self. /// Get the NSEnumerator implementation for self.
/// _HashableTypedNative${Self}Storage overloads this to give /// _HashableTypedNative${Self}Storage overloads this to give
/// _NativeSelfNSEnumerator proper type parameters. /// _NativeSelfNSEnumerator proper type parameters.
@objc
func enumerator() -> _NSEnumerator { func enumerator() -> _NSEnumerator {
return _Native${Self}NSEnumerator<${AnyTypeParameters}>( return _Native${Self}NSEnumerator<${AnyTypeParameters}>(
_Native${Self}Buffer(_storage: self)) _Native${Self}Buffer(_storage: self))
@@ -2646,6 +2655,7 @@ internal class _TypedNative${Self}Storage<${TypeParameters}> :
// This type is made with allocWithTailElems, so no init is ever called. // This type is made with allocWithTailElems, so no init is ever called.
// But we still need to have an init to satisfy the compiler. // But we still need to have an init to satisfy the compiler.
@nonobjc
override internal init(_doNotCallMe: ()) { override internal init(_doNotCallMe: ()) {
_sanityCheckFailure("Only create this by calling Buffer's inits") _sanityCheckFailure("Only create this by calling Buffer's inits")
} }
@@ -2680,6 +2690,7 @@ final internal class _HashableTypedNative${Self}Storage<${TypeParametersDecl}> :
// This type is made with allocWithTailElems, so no init is ever called. // This type is made with allocWithTailElems, so no init is ever called.
// But we still need to have an init to satisfy the compiler. // But we still need to have an init to satisfy the compiler.
@nonobjc
override internal init(_doNotCallMe: ()) { override internal init(_doNotCallMe: ()) {
_sanityCheckFailure("Only create this by calling Buffer's inits'") _sanityCheckFailure("Only create this by calling Buffer's inits'")
} }
@@ -2744,7 +2755,8 @@ final internal class _HashableTypedNative${Self}Storage<${TypeParametersDecl}> :
return stored return stored
} }
internal func getObjectFor(_ aKey: AnyObject) -> AnyObject? { @nonobjc
internal func getObjectFor(_ aKey: AnyObject) -> AnyObject? {
guard let nativeKey = _conditionallyBridgeFromObjectiveC(aKey, Key.self) guard let nativeKey = _conditionallyBridgeFromObjectiveC(aKey, Key.self)
else { return nil } else { return nil }
@@ -3479,6 +3491,7 @@ final internal class _SwiftDeferredNS${Self}<${TypeParametersDecl}>
internal typealias Value = Element internal typealias Value = Element
%end %end
@nonobjc
internal init(minimumCapacity: Int = 2) { internal init(minimumCapacity: Int = 2) {
nativeBuffer = NativeBuffer(minimumCapacity: minimumCapacity) nativeBuffer = NativeBuffer(minimumCapacity: minimumCapacity)
super.init() super.init()
@@ -3493,6 +3506,7 @@ final internal class _SwiftDeferredNS${Self}<${TypeParametersDecl}>
// operations on it. // operations on it.
// //
// Do not access this property directly. // Do not access this property directly.
@nonobjc
internal var _heapStorageBridged_DoNotUse: AnyObject? internal var _heapStorageBridged_DoNotUse: AnyObject?
/// The unbridged elements. /// The unbridged elements.
@@ -3584,12 +3598,14 @@ final internal class _SwiftDeferredNS${Self}<${TypeParametersDecl}>
/// Returns the pointer to the stored property, which contains bridged /// Returns the pointer to the stored property, which contains bridged
/// ${Self} elements. /// ${Self} elements.
@nonobjc
internal var _heapStorageBridgedPtr: UnsafeMutablePointer<AnyObject?> { internal var _heapStorageBridgedPtr: UnsafeMutablePointer<AnyObject?> {
return _getUnsafePointerToStoredProperties(self).assumingMemoryBound( return _getUnsafePointerToStoredProperties(self).assumingMemoryBound(
to: Optional<AnyObject>.self) to: Optional<AnyObject>.self)
} }
/// The buffer for bridged ${Self} elements, if present. /// The buffer for bridged ${Self} elements, if present.
@nonobjc
internal var _bridgedStorage: internal var _bridgedStorage:
BridgedBuffer.RawStorage? { BridgedBuffer.RawStorage? {
get { get {
@@ -3601,6 +3617,7 @@ final internal class _SwiftDeferredNS${Self}<${TypeParametersDecl}>
} }
/// Attach a buffer for bridged ${Self} elements. /// Attach a buffer for bridged ${Self} elements.
@nonobjc
internal func _initializeHeapStorageBridged(_ newStorage: AnyObject) { internal func _initializeHeapStorageBridged(_ newStorage: AnyObject) {
_stdlib_atomicInitializeARCRef( _stdlib_atomicInitializeARCRef(
object: _heapStorageBridgedPtr, desired: newStorage) object: _heapStorageBridgedPtr, desired: newStorage)
@@ -3611,6 +3628,7 @@ final internal class _SwiftDeferredNS${Self}<${TypeParametersDecl}>
return BridgedBuffer(_storage: _bridgedStorage!) return BridgedBuffer(_storage: _bridgedStorage!)
} }
@nonobjc
internal func bridgeEverything() { internal func bridgeEverything() {
if _fastPath(_bridgedStorage != nil) { if _fastPath(_bridgedStorage != nil) {
return return
@@ -3643,6 +3661,7 @@ final internal class _SwiftDeferredNS${Self}<${TypeParametersDecl}>
%if Self == 'Dictionary': %if Self == 'Dictionary':
@nonobjc
internal func bridgedAllKeysAndValues( internal func bridgedAllKeysAndValues(
_ objects: UnsafeMutablePointer<AnyObject>?, _ objects: UnsafeMutablePointer<AnyObject>?,
_ keys: UnsafeMutablePointer<AnyObject>? _ keys: UnsafeMutablePointer<AnyObject>?
@@ -3693,6 +3712,7 @@ final internal class _SwiftDeferredNS${Self}<${TypeParametersDecl}>
return nativeBuffer.count return nativeBuffer.count
} }
@nonobjc
internal func bridgingObjectForKey(_ aKey: AnyObject) internal func bridgingObjectForKey(_ aKey: AnyObject)
-> AnyObject? { -> AnyObject? {
guard let nativeKey = _conditionallyBridgeFromObjectiveC(aKey, Key.self) guard let nativeKey = _conditionallyBridgeFromObjectiveC(aKey, Key.self)
@@ -3707,6 +3727,7 @@ final internal class _SwiftDeferredNS${Self}<${TypeParametersDecl}>
return nil return nil
} }
@objc
internal func enumerator() -> _NSEnumerator { internal func enumerator() -> _NSEnumerator {
bridgeEverything() bridgeEverything()
return _Native${Self}NSEnumerator<${AnyTypeParameters}>(bridgedBuffer) return _Native${Self}NSEnumerator<${AnyTypeParameters}>(bridgedBuffer)

View File

@@ -492,7 +492,7 @@ class _SwiftNativeNSEnumerator {}
// FIXME(ABI)#60 : move into the Foundation overlay and remove 'open' // FIXME(ABI)#60 : move into the Foundation overlay and remove 'open'
@objc @_swift_native_objc_runtime_base(_SwiftNativeNSDataBase) @objc @_swift_native_objc_runtime_base(_SwiftNativeNSDataBase)
open class _SwiftNativeNSData { open class _SwiftNativeNSData {
public init() {} @objc public init() {}
} }
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//

View File

@@ -214,19 +214,22 @@ public final class _NSContiguousString : _SwiftNativeNSString {
super.init() super.init()
} }
@objc
init(coder aDecoder: AnyObject) { init(coder aDecoder: AnyObject) {
_sanityCheckFailure("init(coder:) not implemented for _NSContiguousString") _sanityCheckFailure("init(coder:) not implemented for _NSContiguousString")
} }
@objc
func length() -> Int { func length() -> Int {
return _core.count return _core.count
} }
@objc
func characterAtIndex(_ index: Int) -> UInt16 { func characterAtIndex(_ index: Int) -> UInt16 {
return _core[index] return _core[index]
} }
@inline(__always) // Performance: To save on reference count operations. @objc @inline(__always) // Performance: To save on reference count operations.
func getCharacters( func getCharacters(
_ buffer: UnsafeMutablePointer<UInt16>, _ buffer: UnsafeMutablePointer<UInt16>,
range aRange: _SwiftNSRange) { range aRange: _SwiftNSRange) {
@@ -255,20 +258,20 @@ public final class _NSContiguousString : _SwiftNativeNSString {
// //
// Implement sub-slicing without adding layers of wrapping // Implement sub-slicing without adding layers of wrapping
// //
func substringFromIndex(_ start: Int) -> _NSContiguousString { @objc func substringFromIndex(_ start: Int) -> _NSContiguousString {
return _NSContiguousString(_core[Int(start)..<Int(_core.count)]) return _NSContiguousString(_core[Int(start)..<Int(_core.count)])
} }
func substringToIndex(_ end: Int) -> _NSContiguousString { @objc func substringToIndex(_ end: Int) -> _NSContiguousString {
return _NSContiguousString(_core[0..<Int(end)]) return _NSContiguousString(_core[0..<Int(end)])
} }
func substringWithRange(_ aRange: _SwiftNSRange) -> _NSContiguousString { @objc func substringWithRange(_ aRange: _SwiftNSRange) -> _NSContiguousString {
return _NSContiguousString( return _NSContiguousString(
_core[Int(aRange.location)..<Int(aRange.location + aRange.length)]) _core[Int(aRange.location)..<Int(aRange.location + aRange.length)])
} }
func copy() -> AnyObject { @objc func copy() -> AnyObject {
// Since this string is immutable we can just return ourselves. // Since this string is immutable we can just return ourselves.
return self return self
} }

View File

@@ -148,15 +148,18 @@ extension _SwiftNativeNSArrayWithContiguousStorage : _NSArrayCore {
// //
// Do not access this property directly. // Do not access this property directly.
@_versioned @_versioned
@nonobjc
internal var _heapBufferBridged_DoNotUse: AnyObject? internal var _heapBufferBridged_DoNotUse: AnyObject?
// When this class is allocated inline, this property can become a // When this class is allocated inline, this property can become a
// computed one. // computed one.
@_versioned @_versioned
@nonobjc
internal let _nativeStorage: _ContiguousArrayStorageBase internal let _nativeStorage: _ContiguousArrayStorageBase
@_inlineable @_inlineable
@_versioned @_versioned
@nonobjc
internal var _heapBufferBridgedPtr: UnsafeMutablePointer<AnyObject?> { internal var _heapBufferBridgedPtr: UnsafeMutablePointer<AnyObject?> {
return _getUnsafePointerToStoredProperties(self).assumingMemoryBound( return _getUnsafePointerToStoredProperties(self).assumingMemoryBound(
to: Optional<AnyObject>.self) to: Optional<AnyObject>.self)
@@ -175,6 +178,7 @@ extension _SwiftNativeNSArrayWithContiguousStorage : _NSArrayCore {
} }
@_versioned @_versioned
@nonobjc
internal init(_nativeStorage: _ContiguousArrayStorageBase) { internal init(_nativeStorage: _ContiguousArrayStorageBase) {
self._nativeStorage = _nativeStorage self._nativeStorage = _nativeStorage
} }
@@ -271,6 +275,7 @@ internal class _ContiguousArrayStorageBase
@_versioned @_versioned
final var countAndCapacity: _ArrayBody final var countAndCapacity: _ArrayBody
@nonobjc
init(_doNotCallMeBase: ()) { init(_doNotCallMeBase: ()) {
_sanityCheckFailure("creating instance of _ContiguousArrayStorageBase") _sanityCheckFailure("creating instance of _ContiguousArrayStorageBase")
} }
@@ -300,6 +305,7 @@ internal class _ContiguousArrayStorageBase
} }
@_versioned @_versioned
@nonobjc
internal func _getNonVerbatimBridgedCount() -> Int { internal func _getNonVerbatimBridgedCount() -> Int {
_sanityCheckFailure( _sanityCheckFailure(
"Concrete subclasses must implement _getNonVerbatimBridgedCount") "Concrete subclasses must implement _getNonVerbatimBridgedCount")