DocSupport: don't assume we've printed the first extension when merging several together. rdar://39887195

When printing the content of several extensions into a
synthesized one, we shouldn't assume the first extension in the
group always gets printed.
This commit is contained in:
Xi Ge
2018-05-02 17:44:20 -07:00
parent fc99de452d
commit 714775eb0a
3 changed files with 9 additions and 4 deletions

View File

@@ -622,10 +622,11 @@ void swift::ide::printSubmoduleInterface(
// For sub-decls, all extensions should be printed.
SynthesizedExtensionAnalyzer::MergeGroupKind::All,
[&](ArrayRef<ExtensionInfo> Decls) {
// Whether we've started the extension merge group in printing.
bool Opened = false;
for (auto ET : Decls) {
AdjustedOptions.BracketOptions = {
ET.Ext, Decls.front().Ext == ET.Ext,
Decls.back().Ext == ET.Ext, true};
AdjustedOptions.BracketOptions = { ET.Ext, !Opened,
Decls.back().Ext == ET.Ext, true};
if (AdjustedOptions.BracketOptions.shouldOpenExtension(
ET.Ext))
Printer << "\n";
@@ -636,7 +637,8 @@ void swift::ide::printSubmoduleInterface(
else
AdjustedOptions.initForSynthesizedExtension(NTD);
}
ET.Ext->print(Printer, AdjustedOptions);
// Set opened if we actually printed this extension.
Opened |= ET.Ext->print(Printer, AdjustedOptions);
if (ET.IsSynthesized)
AdjustedOptions.clearSynthesizedExtension();
if (AdjustedOptions.BracketOptions.shouldCloseExtension(