@@ -6178,29 +6178,34 @@ Constraint<T> GenericSignatureBuilder::checkConstraintList(
6178
6178
6179
6179
// / Determine whether this is a redundantly inheritable Objective-C protocol.
6180
6180
// /
6181
- // / If we do have a redundantly inheritable Objective-C protocol, record that
6182
- // / the conformance was restated on the protocol whose requirement signature
6183
- // / we are computing.
6181
+ // / A redundantly-inheritable Objective-C protocol is one where we will
6182
+ // / silently accept a directly-stated redundant conformance to this protocol,
6183
+ // / and emit this protocol in the list of "inherited" protocols. There are
6184
+ // / two cases where we allow this:
6184
6185
// /
6185
- // / At present, there is only one such protocol that we know about:
6186
- // / JavaScriptCore's JSExport.
6186
+ // 1) For a protocol defined in Objective-C, so that we will match Clang's
6187
+ // / behavior, and
6188
+ // / 2) For an @objc protocol defined in Swift that directly inherits from
6189
+ // / JavaScriptCore's JSExport, which depends on this behavior.
6187
6190
static bool isRedundantlyInheritableObjCProtocol (
6188
6191
ProtocolDecl *proto,
6189
6192
const RequirementSource *source) {
6190
6193
if (!proto->isObjC ()) return false ;
6191
6194
6192
- // Only JSExport protocol behaves this way.
6193
- if (!proto->getName ().is (" JSExport" )) return false ;
6194
-
6195
6195
// Only do this for the requirement signature computation.
6196
6196
auto parentSource = source->parent ;
6197
6197
if (!parentSource ||
6198
6198
parentSource->kind != RequirementSource::RequirementSignatureSelf)
6199
6199
return false ;
6200
6200
6201
+ // Check the two conditions in which we will suppress the diagnostic and
6202
+ // emit the redundant inheritance.
6203
+ auto inheritingProto = parentSource->getProtocolDecl ();
6204
+ if (!inheritingProto->hasClangNode () && !proto->getName ().is (" JSExport" ))
6205
+ return false ;
6206
+
6201
6207
// If the inheriting protocol already has @_restatedObjCConformance with
6202
6208
// this protocol, we're done.
6203
- auto inheritingProto = parentSource->getProtocolDecl ();
6204
6209
for (auto *attr : inheritingProto->getAttrs ()
6205
6210
.getAttributes <RestatedObjCConformanceAttr>()) {
6206
6211
if (attr->Proto == proto) return true ;
0 commit comments