mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Use ValueDecl::isDynamic() instead of getAttrs().hasAttribute<DynamicAttr>()
This commit is contained in:
@@ -3790,8 +3790,7 @@ bool AbstractStorageDecl::requiresForeignGetterAndSetter() const {
|
|||||||
return true;
|
return true;
|
||||||
// Otherwise, we only dispatch by @objc if the declaration is dynamic or
|
// Otherwise, we only dispatch by @objc if the declaration is dynamic or
|
||||||
// NSManaged.
|
// NSManaged.
|
||||||
return getAttrs().hasAttribute<DynamicAttr>() ||
|
return isDynamic() || getAttrs().hasAttribute<NSManagedAttr>();
|
||||||
getAttrs().hasAttribute<NSManagedAttr>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ swift::getMethodDispatch(AbstractFunctionDecl *method) {
|
|||||||
if (fd->isAccessor() && fd->getAccessorStorageDecl()->hasClangNode())
|
if (fd->isAccessor() && fd->getAccessorStorageDecl()->hasClangNode())
|
||||||
return MethodDispatch::Class;
|
return MethodDispatch::Class;
|
||||||
}
|
}
|
||||||
if (method->getAttrs().hasAttribute<DynamicAttr>())
|
if (method->isDynamic())
|
||||||
return MethodDispatch::Class;
|
return MethodDispatch::Class;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,20 +96,20 @@ bool swift::requiresForeignEntryPoint(ValueDecl *vd) {
|
|||||||
if (fd->isGetterOrSetter())
|
if (fd->isGetterOrSetter())
|
||||||
return requiresForeignEntryPoint(fd->getAccessorStorageDecl());
|
return requiresForeignEntryPoint(fd->getAccessorStorageDecl());
|
||||||
|
|
||||||
return fd->getAttrs().hasAttribute<DynamicAttr>();
|
return fd->isDynamic();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (auto *cd = dyn_cast<ConstructorDecl>(vd)) {
|
if (auto *cd = dyn_cast<ConstructorDecl>(vd)) {
|
||||||
if (cd->hasClangNode())
|
if (cd->hasClangNode())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return cd->getAttrs().hasAttribute<DynamicAttr>();
|
return cd->isDynamic();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (auto *asd = dyn_cast<AbstractStorageDecl>(vd))
|
if (auto *asd = dyn_cast<AbstractStorageDecl>(vd))
|
||||||
return asd->requiresForeignGetterAndSetter();
|
return asd->requiresForeignGetterAndSetter();
|
||||||
|
|
||||||
return vd->getAttrs().hasAttribute<DynamicAttr>();
|
return vd->isDynamic();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// TODO: We should consult the cached LoweredLocalCaptures the SIL
|
/// TODO: We should consult the cached LoweredLocalCaptures the SIL
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ SILGenFunction::emitSiblingMethodRef(SILLocation loc,
|
|||||||
// If the method is dynamic, access it through runtime-hookable virtual
|
// If the method is dynamic, access it through runtime-hookable virtual
|
||||||
// dispatch (viz. objc_msgSend for now).
|
// dispatch (viz. objc_msgSend for now).
|
||||||
if (methodConstant.hasDecl()
|
if (methodConstant.hasDecl()
|
||||||
&& methodConstant.getDecl()->getAttrs().hasAttribute<DynamicAttr>())
|
&& methodConstant.getDecl()->isDynamic())
|
||||||
methodValue = emitDynamicMethodRef(loc, methodConstant,
|
methodValue = emitDynamicMethodRef(loc, methodConstant,
|
||||||
SGM.Types.getConstantInfo(methodConstant));
|
SGM.Types.getConstantInfo(methodConstant));
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -720,7 +720,7 @@ namespace {
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// If the declaration is dynamic, there's no materializeForSet.
|
// If the declaration is dynamic, there's no materializeForSet.
|
||||||
if (decl->getAttrs().hasAttribute<DynamicAttr>())
|
if (decl->isDynamic())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// If the declaration was imported from C, we won't gain anything
|
// If the declaration was imported from C, we won't gain anything
|
||||||
|
|||||||
@@ -3164,7 +3164,7 @@ getWitnessDispatchKind(Type selfType, SILDeclRef witness, bool isFree) {
|
|||||||
auto *decl = witness.getDecl();
|
auto *decl = witness.getDecl();
|
||||||
|
|
||||||
// If the witness is dynamic, go through dynamic dispatch.
|
// If the witness is dynamic, go through dynamic dispatch.
|
||||||
if (decl->getAttrs().hasAttribute<DynamicAttr>())
|
if (decl->isDynamic())
|
||||||
return WitnessDispatchKind::Dynamic;
|
return WitnessDispatchKind::Dynamic;
|
||||||
|
|
||||||
bool isFinal = (decl->isFinal() || C->isFinal());
|
bool isFinal = (decl->isFinal() || C->isFinal());
|
||||||
|
|||||||
@@ -6016,7 +6016,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void visitDynamicAttr(DynamicAttr *attr) {
|
void visitDynamicAttr(DynamicAttr *attr) {
|
||||||
if (!Override->getAttrs().hasAttribute<DynamicAttr>())
|
if (!Override->isDynamic())
|
||||||
// Dynamic is inherited.
|
// Dynamic is inherited.
|
||||||
Override->getAttrs().add(
|
Override->getAttrs().add(
|
||||||
new (TC.Context) DynamicAttr(/*implicit*/true));
|
new (TC.Context) DynamicAttr(/*implicit*/true));
|
||||||
|
|||||||
@@ -2,11 +2,11 @@
|
|||||||
@_exported import CoreGraphics
|
@_exported import CoreGraphics
|
||||||
@_exported import Foundation
|
@_exported import Foundation
|
||||||
|
|
||||||
@_silgen_name("swift_StringToNSString") internal
|
@_silgen_name("swift_StringToNSString")
|
||||||
func _convertStringToNSString(_ string: String) -> NSString
|
public func _convertStringToNSString(_ string: String) -> NSString
|
||||||
|
|
||||||
@_silgen_name("swift_NSStringToString") internal
|
@_silgen_name("swift_NSStringToString")
|
||||||
func _convertNSStringToString(_ nsstring: NSString?) -> String
|
public func _convertNSStringToString(_ nsstring: NSString?) -> String
|
||||||
|
|
||||||
public func == (lhs: NSObject, rhs: NSObject) -> Bool {
|
public func == (lhs: NSObject, rhs: NSObject) -> Bool {
|
||||||
return lhs.isEqual(rhs)
|
return lhs.isEqual(rhs)
|
||||||
@@ -15,33 +15,33 @@ public func == (lhs: NSObject, rhs: NSObject) -> Bool {
|
|||||||
public let NSUTF8StringEncoding: UInt = 8
|
public let NSUTF8StringEncoding: UInt = 8
|
||||||
|
|
||||||
// NSArray bridging entry points
|
// NSArray bridging entry points
|
||||||
func _convertNSArrayToArray<T>(_ nsarr: NSArray?) -> [T] {
|
public func _convertNSArrayToArray<T>(_ nsarr: NSArray?) -> [T] {
|
||||||
return [T]()
|
return [T]()
|
||||||
}
|
}
|
||||||
|
|
||||||
func _convertArrayToNSArray<T>(_ arr: [T]) -> NSArray {
|
public func _convertArrayToNSArray<T>(_ arr: [T]) -> NSArray {
|
||||||
return NSArray()
|
return NSArray()
|
||||||
}
|
}
|
||||||
|
|
||||||
// NSDictionary bridging entry points
|
// NSDictionary bridging entry points
|
||||||
internal func _convertDictionaryToNSDictionary<Key, Value>(
|
public func _convertDictionaryToNSDictionary<Key, Value>(
|
||||||
_ d: Dictionary<Key, Value>
|
_ d: Dictionary<Key, Value>
|
||||||
) -> NSDictionary {
|
) -> NSDictionary {
|
||||||
return NSDictionary()
|
return NSDictionary()
|
||||||
}
|
}
|
||||||
|
|
||||||
internal func _convertNSDictionaryToDictionary<K: NSObject, V: AnyObject>(
|
public func _convertNSDictionaryToDictionary<K: NSObject, V: AnyObject>(
|
||||||
_ d: NSDictionary?
|
_ d: NSDictionary?
|
||||||
) -> Dictionary<K, V> {
|
) -> Dictionary<K, V> {
|
||||||
return Dictionary<K, V>()
|
return Dictionary<K, V>()
|
||||||
}
|
}
|
||||||
|
|
||||||
// NSSet bridging entry points
|
// NSSet bridging entry points
|
||||||
internal func _convertSetToNSSet<T : Hashable>(_ s: Set<T>) -> NSSet {
|
public func _convertSetToNSSet<T>(_ s: Set<T>) -> NSSet {
|
||||||
return NSSet()
|
return NSSet()
|
||||||
}
|
}
|
||||||
|
|
||||||
internal func _convertNSSetToSet<T : Hashable>(_ s: NSSet?) -> Set<T> {
|
public func _convertNSSetToSet<T>(_ s: NSSet?) -> Set<T> {
|
||||||
return Set<T>()
|
return Set<T>()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,7 +207,7 @@ extension NSError : Error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@_silgen_name("swift_convertNSErrorToError")
|
@_silgen_name("swift_convertNSErrorToError")
|
||||||
func _convertNSErrorToError(_ string: NSError?) -> Error
|
public func _convertNSErrorToError(_ string: NSError?) -> Error
|
||||||
|
|
||||||
@_silgen_name("swift_convertErrorToNSError")
|
@_silgen_name("swift_convertErrorToNSError")
|
||||||
func _convertErrorToNSError(_ string: Error) -> NSError
|
public func _convertErrorToNSError(_ string: Error) -> NSError
|
||||||
|
|||||||
@@ -2,11 +2,11 @@
|
|||||||
@_exported import CoreGraphics
|
@_exported import CoreGraphics
|
||||||
@_exported import Foundation
|
@_exported import Foundation
|
||||||
|
|
||||||
@_silgen_name("swift_StringToNSString") internal
|
@_silgen_name("swift_StringToNSString")
|
||||||
func _convertStringToNSString(_ string: String) -> NSString
|
public func _convertStringToNSString(_ string: String) -> NSString
|
||||||
|
|
||||||
@_silgen_name("swift_NSStringToString") internal
|
@_silgen_name("swift_NSStringToString")
|
||||||
func _convertNSStringToString(_ nsstring: NSString?) -> String
|
public func _convertNSStringToString(_ nsstring: NSString?) -> String
|
||||||
|
|
||||||
public func == (lhs: NSObject, rhs: NSObject) -> Bool {
|
public func == (lhs: NSObject, rhs: NSObject) -> Bool {
|
||||||
return lhs.isEqual(rhs)
|
return lhs.isEqual(rhs)
|
||||||
@@ -15,33 +15,33 @@ public func == (lhs: NSObject, rhs: NSObject) -> Bool {
|
|||||||
public let NSUTF8StringEncoding: UInt = 8
|
public let NSUTF8StringEncoding: UInt = 8
|
||||||
|
|
||||||
// NSArray bridging entry points
|
// NSArray bridging entry points
|
||||||
func _convertNSArrayToArray<T>(_ nsarr: NSArray?) -> [T] {
|
public func _convertNSArrayToArray<T>(_ nsarr: NSArray?) -> [T] {
|
||||||
return [T]()
|
return [T]()
|
||||||
}
|
}
|
||||||
|
|
||||||
func _convertArrayToNSArray<T>(_ arr: [T]) -> NSArray {
|
public func _convertArrayToNSArray<T>(_ arr: [T]) -> NSArray {
|
||||||
return NSArray()
|
return NSArray()
|
||||||
}
|
}
|
||||||
|
|
||||||
// NSDictionary bridging entry points
|
// NSDictionary bridging entry points
|
||||||
internal func _convertDictionaryToNSDictionary<Key, Value>(
|
public func _convertDictionaryToNSDictionary<Key, Value>(
|
||||||
_ d: Dictionary<Key, Value>
|
_ d: Dictionary<Key, Value>
|
||||||
) -> NSDictionary {
|
) -> NSDictionary {
|
||||||
return NSDictionary()
|
return NSDictionary()
|
||||||
}
|
}
|
||||||
|
|
||||||
internal func _convertNSDictionaryToDictionary<K: NSObject, V: AnyObject>(
|
public func _convertNSDictionaryToDictionary<K: NSObject, V: AnyObject>(
|
||||||
_ d: NSDictionary?
|
_ d: NSDictionary?
|
||||||
) -> Dictionary<K, V> {
|
) -> Dictionary<K, V> {
|
||||||
return Dictionary<K, V>()
|
return Dictionary<K, V>()
|
||||||
}
|
}
|
||||||
|
|
||||||
// NSSet bridging entry points
|
// NSSet bridging entry points
|
||||||
internal func _convertSetToNSSet<T>(_ s: Set<T>) -> NSSet {
|
public func _convertSetToNSSet<T>(_ s: Set<T>) -> NSSet {
|
||||||
return NSSet()
|
return NSSet()
|
||||||
}
|
}
|
||||||
|
|
||||||
internal func _convertNSSetToSet<T>(_ s: NSSet?) -> Set<T> {
|
public func _convertNSSetToSet<T>(_ s: NSSet?) -> Set<T> {
|
||||||
return Set<T>()
|
return Set<T>()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -272,10 +272,10 @@ extension NSArray {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@_silgen_name("swift_convertNSErrorToError")
|
@_silgen_name("swift_convertNSErrorToError")
|
||||||
func _convertNSErrorToError(_ string: NSError?) -> Error
|
public func _convertNSErrorToError(_ string: NSError?) -> Error
|
||||||
|
|
||||||
@_silgen_name("swift_convertErrorToNSError")
|
@_silgen_name("swift_convertErrorToNSError")
|
||||||
func _convertErrorToNSError(_ string: Error) -> NSError
|
public func _convertErrorToNSError(_ string: Error) -> NSError
|
||||||
|
|
||||||
/// An internal protocol to represent Swift error enums that map to standard
|
/// An internal protocol to represent Swift error enums that map to standard
|
||||||
/// Cocoa NSError domains.
|
/// Cocoa NSError domains.
|
||||||
|
|||||||
@@ -32,11 +32,11 @@ func _convertNSDictionaryToDictionary<K: NSObject, V: AnyObject>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NSSet bridging entry points
|
// NSSet bridging entry points
|
||||||
func _convertSetToNSSet<T: Hashable>(s: Set<T>) -> NSSet {
|
func _convertSetToNSSet<T>(s: Set<T>) -> NSSet {
|
||||||
return NSSet()
|
return NSSet()
|
||||||
}
|
}
|
||||||
|
|
||||||
func _convertNSSetToSet<T: NSObject>(s: NSSet?) -> Set<T> {
|
func _convertNSSetToSet<T>(s: NSSet?) -> Set<T> {
|
||||||
return Set<T>()
|
return Set<T>()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user