File tree Expand file tree Collapse file tree 2 files changed +19
-5
lines changed Expand file tree Collapse file tree 2 files changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -4182,8 +4182,8 @@ bool VarDecl::isSelfParameter() const {
4182
4182
return false ;
4183
4183
}
4184
4184
4185
- // / Return true if this stored property needs to be accessed with getters and
4186
- // / setters for Objective-C.
4185
+ // / Return true if this stored property has a getter and
4186
+ // / setter that are accessible from Objective-C.
4187
4187
bool AbstractStorageDecl::hasForeignGetterAndSetter () const {
4188
4188
if (auto override = getOverriddenDecl ())
4189
4189
return override ->hasForeignGetterAndSetter ();
@@ -4204,9 +4204,11 @@ bool AbstractStorageDecl::requiresForeignGetterAndSetter() const {
4204
4204
// Imported accessors are foreign and only have objc entry points.
4205
4205
if (hasClangNode ())
4206
4206
return true ;
4207
- // Otherwise, we only dispatch by @objc if the declaration is dynamic or
4208
- // NSManaged.
4209
- return isDynamic () || getAttrs ().hasAttribute <NSManagedAttr>();
4207
+ // Otherwise, we only dispatch by @objc if the declaration is dynamic,
4208
+ // NSManaged, or dispatched through an ObjC protocol.
4209
+ return isDynamic ()
4210
+ || getAttrs ().hasAttribute <NSManagedAttr>()
4211
+ || (isa<ProtocolDecl>(getDeclContext ()) && isProtocolRequirement ());
4210
4212
}
4211
4213
4212
4214
Original file line number Diff line number Diff line change @@ -76,3 +76,15 @@ func nonobjcExtensionOfObjCClass() {
76
76
_ = \NSObject . dynamic
77
77
78
78
}
79
+
80
+ @objc protocol ObjCProto {
81
+ var objcRequirement : Int { get set }
82
+ }
83
+
84
+ // CHECK-LABEL: sil hidden @{{.*}}ProtocolRequirement
85
+ func objcProtocolRequirement< T: ObjCProto > ( _: T ) {
86
+ // CHECK: keypath {{.*}} id #ObjCProto.objcRequirement!getter.1.foreign
87
+ _ = \T . objcRequirement
88
+ // CHECK: keypath {{.*}} id #ObjCProto.objcRequirement!getter.1.foreign
89
+ _ = \ObjCProto . objcRequirement
90
+ }
You can’t perform that action at this time.
0 commit comments