Skip to content

Commit 87c1c5c

Browse files
committed
[AST] Enable inheritance node for protocol conformance
rdar://problem/49043711
1 parent db2c117 commit 87c1c5c

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

lib/AST/DocComment.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -479,12 +479,10 @@ swift::getCascadingDocComment(swift::markup::MarkupContext &MC, const Decl *D) {
479479
auto *doc = getSingleDocComment(MC, docD);
480480
assert(doc && "getDocCommentProvidingDecl() returned decl with no comment");
481481

482-
// Iff the doc is inherited from overridden decl, add a note about that.
483-
// FIXME: This is inconsistent <rdar://problem/49043711>, but let's keep the
484-
// behavior for now.
482+
// If the doc-comment is inherited from other decl, add a note about it.
485483
if (docD != D)
486-
if (auto baseClassD = docD->getDeclContext()->getSelfClassDecl())
487-
doc->addInheritanceNote(MC, baseClassD);
484+
if (auto baseD = docD->getDeclContext()->getSelfNominalTypeDecl())
485+
doc->addInheritanceNote(MC, baseD);
488486

489487
return doc;
490488
}

test/IDE/comment_inherited_protocol.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,23 +63,23 @@ protocol ChildProtocol : ParentProtocol1, ParentProtocol2 {
6363
extension ChildProtocol {
6464
// Should come from ParentProtocol1.
6565
func onlyParent1() {}
66-
// CHECK: Func/onlyParent1 {{.*}} DocCommentAsXML=[<Function file="{{.*}}" line="{{.*}}" column="{{.*}}"><Name>onlyParent1()</Name><USR>s:14swift_ide_test13ChildProtocolPAAE11onlyParent1yyF</USR><Declaration>func onlyParent1()</Declaration><CommentParts><Abstract><Para>ParentProtocol1.onlyParent1()</Para></Abstract></CommentParts></Function>]
66+
// CHECK: Func/onlyParent1 {{.*}} DocCommentAsXML=[<Function file="{{.*}}" line="{{.*}}" column="{{.*}}"><Name>onlyParent1()</Name><USR>s:14swift_ide_test13ChildProtocolPAAE11onlyParent1yyF</USR><Declaration>func onlyParent1()</Declaration><CommentParts><Abstract><Para>ParentProtocol1.onlyParent1()</Para></Abstract><Discussion><Note><Para>This documentation comment was inherited from <codeVoice>ParentProtocol1</codeVoice>.</Para></Note></Discussion></CommentParts></Function>]
6767

6868
// Should come from ParentProtocol1.
6969
var onlyParent1Var: Int { return 0 }
70-
// CHECK: Var/onlyParent1Var {{.*}} DocCommentAsXML=[<Other file="{{.*}}" line="{{.*}}" column="{{.*}}"><Name>onlyParent1Var</Name><USR>s:14swift_ide_test13ChildProtocolPAAE14onlyParent1VarSivp</USR><Declaration>var onlyParent1Var: Int { get }</Declaration><CommentParts><Abstract><Para>ParentProtocol.onlyParent1Var</Para></Abstract></CommentParts></Other>]
70+
// CHECK: Var/onlyParent1Var {{.*}} DocCommentAsXML=[<Other file="{{.*}}" line="{{.*}}" column="{{.*}}"><Name>onlyParent1Var</Name><USR>s:14swift_ide_test13ChildProtocolPAAE14onlyParent1VarSivp</USR><Declaration>var onlyParent1Var: Int { get }</Declaration><CommentParts><Abstract><Para>ParentProtocol.onlyParent1Var</Para></Abstract><Discussion><Note><Para>This documentation comment was inherited from <codeVoice>ParentProtocol1</codeVoice>.</Para></Note></Discussion></CommentParts></Other>]
7171

7272
// Should come from ParentProtocol1.
7373
subscript(index: Int) -> Int { return 0 }
74-
// CHECK: Subscript/subscript {{.*}} DocCommentAsXML=[<Other file="{{.*}}" line="{{.*}}" column="{{.*}}"><Name>subscript(_:)</Name><USR>{{.*}}</USR><Declaration>subscript(index: Int) -&gt; Int { get }</Declaration><CommentParts><Abstract><Para>ParentProtocol.subscript(index:)</Para></Abstract></CommentParts></Other>]
74+
// CHECK: Subscript/subscript {{.*}} DocCommentAsXML=[<Other file="{{.*}}" line="{{.*}}" column="{{.*}}"><Name>subscript(_:)</Name><USR>{{.*}}</USR><Declaration>subscript(index: Int) -&gt; Int { get }</Declaration><CommentParts><Abstract><Para>ParentProtocol.subscript(index:)</Para></Abstract><Discussion><Note><Para>This documentation comment was inherited from <codeVoice>ParentProtocol1</codeVoice>.</Para></Note></Discussion></CommentParts></Other>]
7575

7676
// Should come from ParentProtocol1.
7777
typealias AssocType = Int
78-
// CHECK: TypeAlias/AssocType {{.*}} DocCommentAsXML=[<Other file="{{.*}}" line="{{.*}}" column="{{.*}}"><Name>AssocType</Name><USR>s:14swift_ide_test13ChildProtocolPAAE9AssocTypea</USR><Declaration>typealias AssocType = Int</Declaration><CommentParts><Abstract><Para>ParentProtocol.AssocType</Para></Abstract></CommentParts></Other>]
78+
// CHECK: TypeAlias/AssocType {{.*}} DocCommentAsXML=[<Other file="{{.*}}" line="{{.*}}" column="{{.*}}"><Name>AssocType</Name><USR>s:14swift_ide_test13ChildProtocolPAAE9AssocTypea</USR><Declaration>typealias AssocType = Int</Declaration><CommentParts><Abstract><Para>ParentProtocol.AssocType</Para></Abstract><Discussion><Note><Para>This documentation comment was inherited from <codeVoice>ParentProtocol1</codeVoice>.</Para></Note></Discussion></CommentParts></Other>]
7979

8080
// Should come from ParentProtocol2.
8181
func onlyParent2() {}
82-
// CHECK: Func/onlyParent2 {{.*}} DocCommentAsXML=[<Function file="{{.*}}" line="{{.*}}" column="{{.*}}"><Name>onlyParent2()</Name><USR>s:14swift_ide_test13ChildProtocolPAAE11onlyParent2yyF</USR><Declaration>func onlyParent2()</Declaration><CommentParts><Abstract><Para>ParentProtocol2.onlyParent2()</Para></Abstract></CommentParts></Function>]
82+
// CHECK: Func/onlyParent2 {{.*}} DocCommentAsXML=[<Function file="{{.*}}" line="{{.*}}" column="{{.*}}"><Name>onlyParent2()</Name><USR>s:14swift_ide_test13ChildProtocolPAAE11onlyParent2yyF</USR><Declaration>func onlyParent2()</Declaration><CommentParts><Abstract><Para>ParentProtocol2.onlyParent2()</Para></Abstract><Discussion><Note><Para>This documentation comment was inherited from <codeVoice>ParentProtocol2</codeVoice>.</Para></Note></Discussion></CommentParts></Function>]
8383

8484
// Should show nothing because the requirement is in both parents.
8585
func commonParentRequirement() {}

0 commit comments

Comments
 (0)