@@ -113,19 +113,24 @@ static bool printObjCUSR(const ValueDecl *D, raw_ostream &OS) {
113
113
return printObjCUSRFragment (D, ObjCName.second .getString (Buf), OS);
114
114
}
115
115
116
- static bool ShouldUseObjCUSR (const Decl *D) {
116
+ static bool shouldUseObjCUSR (const Decl *D) {
117
117
// Only the subscript getter/setter are visible to ObjC rather than the
118
118
// subscript itself
119
119
if (isa<SubscriptDecl>(D))
120
120
return false ;
121
121
122
122
auto Parent = D->getDeclContext ()->getInnermostDeclarationDeclContext ();
123
- if (Parent && (!ShouldUseObjCUSR (Parent) || // parent should be visible too
123
+ if (Parent && (!shouldUseObjCUSR (Parent) || // parent should be visible too
124
124
!D->getDeclContext ()->isTypeContext () || // no local decls
125
125
isa<TypeDecl>(D))) // nested types aren't supported
126
126
return false ;
127
127
128
128
if (const ValueDecl *VD = dyn_cast<ValueDecl>(D)) {
129
+ if (auto *PD = dyn_cast<ProtocolDecl>(D))
130
+ if (auto known = PD->getKnownProtocolKind ())
131
+ if (known == KnownProtocolKind::AnyObject)
132
+ return false ;
133
+
129
134
if (isa<EnumElementDecl>(VD))
130
135
return true ;
131
136
return objc_translation::isVisibleToObjC (VD, Accessibility::Internal);
@@ -134,7 +139,7 @@ static bool ShouldUseObjCUSR(const Decl *D) {
134
139
if (const ExtensionDecl *ED = dyn_cast<ExtensionDecl>(D)) {
135
140
if (auto ExtendedType = ED->getExtendedType ()) {
136
141
auto baseClass = ExtendedType->getClassOrBoundGenericClass ();
137
- return baseClass && ShouldUseObjCUSR (baseClass) && !baseClass->isForeign ();
142
+ return baseClass && shouldUseObjCUSR (baseClass) && !baseClass->isForeign ();
138
143
}
139
144
}
140
145
return false ;
@@ -202,7 +207,7 @@ bool ide::printDeclUSR(const ValueDecl *D, raw_ostream &OS) {
202
207
return Ignore;
203
208
}
204
209
205
- if (ShouldUseObjCUSR (D)) {
210
+ if (shouldUseObjCUSR (D)) {
206
211
return printObjCUSR (D, OS);
207
212
}
208
213
@@ -238,7 +243,7 @@ bool ide::printAccessorUSR(const AbstractStorageDecl *D, AccessorKind AccKind,
238
243
// addressor.
239
244
240
245
AbstractStorageDecl *SD = const_cast <AbstractStorageDecl*>(D);
241
- if (ShouldUseObjCUSR (SD)) {
246
+ if (shouldUseObjCUSR (SD)) {
242
247
return printObjCUSRForAccessor (SD, AccKind, OS);
243
248
}
244
249
0 commit comments