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

View File

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

View File

@@ -214,19 +214,22 @@ public final class _NSContiguousString : _SwiftNativeNSString {
super.init()
}
@objc
init(coder aDecoder: AnyObject) {
_sanityCheckFailure("init(coder:) not implemented for _NSContiguousString")
}
@objc
func length() -> Int {
return _core.count
}
@objc
func characterAtIndex(_ index: Int) -> UInt16 {
return _core[index]
}
@inline(__always) // Performance: To save on reference count operations.
@objc @inline(__always) // Performance: To save on reference count operations.
func getCharacters(
_ buffer: UnsafeMutablePointer<UInt16>,
range aRange: _SwiftNSRange) {
@@ -255,20 +258,20 @@ public final class _NSContiguousString : _SwiftNativeNSString {
//
// 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)])
}
func substringToIndex(_ end: Int) -> _NSContiguousString {
@objc func substringToIndex(_ end: Int) -> _NSContiguousString {
return _NSContiguousString(_core[0..<Int(end)])
}
func substringWithRange(_ aRange: _SwiftNSRange) -> _NSContiguousString {
@objc func substringWithRange(_ aRange: _SwiftNSRange) -> _NSContiguousString {
return _NSContiguousString(
_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.
return self
}

View File

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