Skip to content

Commit f7ce3e9

Browse files
committed
[PrintObjC] Fix ReferencedTypeFinder::isConstrained to filter out invertible protocols
The checking should be as simple as checking for `isAny()` or `isAnyObject()` on an existential type because all of the non-inverse protocol requirements are going to form a protocol composition type.
1 parent 72486c9 commit f7ce3e9

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

lib/AST/GenericSignature.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1386,4 +1386,4 @@ void RequirementSignature::getRequirementsWithInverses(
13861386

13871387
reqs.push_back(req);
13881388
}
1389-
}
1389+
}

lib/PrintAsClang/ModuleContentsWriter.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,8 @@ class ReferencedTypeFinder : public TypeDeclFinder {
7878
/// class-bound ("conforms to" AnyObject).
7979
static bool isConstrained(GenericSignature sig,
8080
GenericTypeParamType *paramTy) {
81-
if (sig->getSuperclassBound(paramTy))
82-
return true;
83-
84-
return !sig->getRequiredProtocols(paramTy).empty();
81+
auto existentialTy = sig->getExistentialType(paramTy);
82+
return !(existentialTy->isAny() || existentialTy->isAnyObject());
8583
}
8684

8785
Action visitBoundGenericType(BoundGenericType *boundGeneric) override {

0 commit comments

Comments
 (0)