Skip to content

Commit 83642c6

Browse files
committed
[GSB] Suppress redundant diagnostics for circular protocol inheritance.
1 parent 0a7b977 commit 83642c6

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

lib/AST/GenericSignatureBuilder.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4385,6 +4385,19 @@ void GenericSignatureBuilder::checkConformanceConstraints(
43854385
auto proto = constraint.value;
43864386
assert(proto == entry.first && "Mixed up protocol constraints");
43874387

4388+
// If this conformance requirement recursively makes a protocol
4389+
// conform to itself, don't complain here.
4390+
auto source = constraint.source;
4391+
auto rootSource = source->getRoot();
4392+
if (rootSource->kind == RequirementSource::RequirementSignatureSelf &&
4393+
source != rootSource &&
4394+
proto == rootSource->getProtocolDecl() &&
4395+
rootSource->getRootPotentialArchetype()
4396+
->isInSameEquivalenceClassAs(
4397+
source->getAffectedPotentialArchetype())) {
4398+
return ConstraintRelation::Unrelated;
4399+
}
4400+
43884401
// If this is a redundantly inherited Objective-C protocol, treat it
43894402
// as "unrelated" to silence the warning about the redundant
43904403
// conformance.

0 commit comments

Comments
 (0)