Skip to content

Commit 4bc02d6

Browse files
committed
ModulePrinting: Avoid merging synthesized extensions with comments, and print the comments. rdar://25157796
1 parent d0e1768 commit 4bc02d6

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

lib/AST/ASTPrinter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ struct SynthesizedExtensionAnalyzer::Implementation {
329329
isApplicable(ExtensionDecl *Ext) {
330330
SynthesizedExtensionInfo Result;
331331
std::unique_ptr<ExtensionMergeInfo> MergeInfo(new ExtensionMergeInfo());
332-
MergeInfo->HasDocComment = false;
332+
MergeInfo->HasDocComment = !Ext->getRawComment().isEmpty();
333333
if (!Ext->isConstrainedExtension()) {
334334
if (IncludeUnconditional)
335335
Result.Ext = Ext;

test/IDE/print_synthesized_extensions.swift

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: rm -rf %t && mkdir %t
2-
// RUN: %target-swift-frontend -emit-module-path %t/print_synthesized_extensions.swiftmodule %s
2+
// RUN: %target-swift-frontend -emit-module-path %t/print_synthesized_extensions.swiftmodule -emit-module-doc -emit-module-doc-path %t/print_synthesized_extensions.swiftdoc %s
33
// RUN: %target-swift-ide-test -print-module -annotate-print -synthesize-extension -print-interface -module-to-print=print_synthesized_extensions -I %t -source-filename=%s > %t.syn.txt
44
// RUN: FileCheck %s < %t.syn.txt
55

@@ -123,6 +123,20 @@ public struct S10 : P1 {
123123
}
124124
}
125125

126+
public protocol P4 {}
127+
128+
/// Extension on P4Func1
129+
public extension P4 {
130+
func P4Func1() {}
131+
}
132+
133+
/// Extension on P4Func2
134+
public extension P4 {
135+
func P4Func2() {}
136+
}
137+
138+
public struct S11 : P4 {}
139+
126140
// CHECK: <synthesized>
127141
// CHECK: extension <ref:Struct>S1</ref> where T : P2 {
128142
// CHECK: <decl:Func>public func <loc>p2member()</loc></decl></synthesized>
@@ -155,6 +169,16 @@ public struct S10 : P1 {
155169
// CHECK: <decl:Func>public func <loc>S9IntFunc()</loc></decl>
156170
// CHECK: }</synthesized>
157171

172+
// CHECK: <synthesized>/// Extension on P4Func1
173+
// CHECK: extension <ref:Struct>S11</ref> {
174+
// CHECK: <decl:Func>public func <loc>P4Func1()</loc></decl>
175+
// CHECK: }</synthesized>
176+
177+
// CHECK: <synthesized>/// Extension on P4Func2
178+
// CHECK: extension <ref:Struct>S11</ref> {
179+
// CHECK: <decl:Func>public func <loc>P4Func2()</loc></decl>
180+
// CHECK: }</synthesized>
181+
158182
// CHECK: <synthesized>
159183
// CHECK: extension <ref:Struct>S4</ref> {
160184
// CHECK: <decl:Func>public func <loc>p1IntFunc(<decl:Param>i: <ref:Struct>Int</ref></decl>)</loc> -> <ref:Struct>Int</ref></decl>

0 commit comments

Comments
 (0)