Skip to content

Commit 6a25198

Browse files
committed
AST: Minor optimization for ProtocolCompositionType handling in 'findExistentialSelfReferences'
1 parent e849375 commit 6a25198

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

lib/AST/Decl.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3847,14 +3847,14 @@ findExistentialSelfReferences(CanGenericSignature existentialSig, Type type,
38473847
return SelfReferenceInfo::forSelfRef(TypePosition::Invariant);
38483848

38493849
// Protocol compositions preserve variance.
3850-
auto constraint = type;
3851-
if (auto existential = constraint->getAs<ExistentialType>())
3852-
constraint = existential->getConstraintType();
3853-
if (auto *comp = constraint->getAs<ProtocolCompositionType>()) {
3854-
// 'Self' may be referenced only in a superclass component.
3855-
if (const auto superclass = comp->getSuperclass()) {
3856-
return findExistentialSelfReferences(existentialSig, superclass,
3857-
position);
3850+
if (auto *existential = type->getAs<ExistentialType>())
3851+
type = existential->getConstraintType();
3852+
if (auto *comp = type->getAs<ProtocolCompositionType>()) {
3853+
// 'Self' may be referenced only in an explicit superclass component.
3854+
for (const auto member : comp->getMembers()) {
3855+
if (member->getClassOrBoundGenericClass()) {
3856+
return findExistentialSelfReferences(existentialSig, member, position);
3857+
}
38583858
}
38593859

38603860
return SelfReferenceInfo();

0 commit comments

Comments
 (0)