Skip to content

Commit e68ab1d

Browse files
author
Nathan Hawes
committed
[SourceKit/DocSupport] Don't synthesize extensions for inherited protocol conformances.
The Base class already includes them, so don't duplicate them in its subclasses. Also stops us including members from extensions of the base class itself. Resolves rdar://problem/50960433
1 parent 5141219 commit e68ab1d

File tree

4 files changed

+653
-1527
lines changed

4 files changed

+653
-1527
lines changed

lib/IDE/IDETypeChecking.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,11 @@ struct SynthesizedExtensionAnalyzer::Implementation {
471471
// We want to visit the protocols of any normal conformances we see, but
472472
// we have to avoid doing this to self-conformances or we can end up with
473473
// a cycle. Otherwise this is cycle-proof on valid code.
474+
// We also want to ignore inherited conformances. Members from these will
475+
// be included in the class they were inherited from.
474476
auto addConformance = [&](ProtocolConformance *Conf) {
477+
if (isa<InheritedProtocolConformance>(Conf))
478+
return;
475479
auto RootConf = Conf->getRootConformance();
476480
if (isa<NormalProtocolConformance>(RootConf))
477481
Unhandled.push_back(RootConf->getProtocol());
@@ -480,10 +484,6 @@ struct SynthesizedExtensionAnalyzer::Implementation {
480484
for (auto *Conf : Target->getLocalConformances()) {
481485
addConformance(Conf);
482486
}
483-
if (auto *CD = dyn_cast<ClassDecl>(Target)) {
484-
if (auto Super = CD->getSuperclassDecl())
485-
Unhandled.push_back(Super);
486-
}
487487
while (!Unhandled.empty()) {
488488
NominalTypeDecl* Back = Unhandled.back();
489489
Unhandled.pop_back();
@@ -493,10 +493,6 @@ struct SynthesizedExtensionAnalyzer::Implementation {
493493
for (auto *Conf : Back->getLocalConformances()) {
494494
addConformance(Conf);
495495
}
496-
if (auto *CD = dyn_cast<ClassDecl>(Back)) {
497-
if (auto Super = CD->getSuperclass())
498-
Unhandled.push_back(Super->getAnyNominal());
499-
}
500496
}
501497

502498
// Merge with actual extensions.

0 commit comments

Comments
 (0)