Skip to content

Commit 64efa48

Browse files
authored
[SourceKit][DocInfo] When the underlying type of a type alias decl exists, report the conformances of the underlying type. rdar://26408167 (#3394)
Showing only the conforming associated types provides little information to doc viewers. This patch digs the underlying type of an associated type to report the conformance info of those.
1 parent 96fcc37 commit 64efa48

File tree

5 files changed

+278
-98
lines changed

5 files changed

+278
-98
lines changed

test/SourceKit/DocSupport/Inputs/cake.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,11 @@ public extension S1 {
5252
public protocol P2 {
5353
@objc optional func foo1()
5454
}
55+
56+
public protocol P3 {
57+
associatedtype T
58+
}
59+
60+
public struct S2 : P3 {
61+
public typealias T = S2
62+
}

test/SourceKit/DocSupport/doc_clang_module.swift.response

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6049,7 +6049,24 @@ var FooSubUnnamedEnumeratorA1: Int { get }
60496049
key.doc.full_as_xml: "<Typedef file=Foo.h line=\"59\" column=\"13\"><Name>FooTypedef1</Name><USR>c:Foo.h@T@FooTypedef1</USR><Declaration>typealias FooTypedef1 = Int32</Declaration><Abstract><Para> Aaa. FooTypedef1. Bbb.</Para></Abstract></Typedef>",
60506050
key.offset: 3028,
60516051
key.length: 29,
6052-
key.fully_annotated_decl: "<decl.typealias><syntaxtype.keyword>typealias</syntaxtype.keyword> <decl.name>FooTypedef1</decl.name> = <ref.struct usr=\"s:Vs5Int32\">Int32</ref.struct></decl.typealias>"
6052+
key.fully_annotated_decl: "<decl.typealias><syntaxtype.keyword>typealias</syntaxtype.keyword> <decl.name>FooTypedef1</decl.name> = <ref.struct usr=\"s:Vs5Int32\">Int32</ref.struct></decl.typealias>",
6053+
key.conforms: [
6054+
{
6055+
key.kind: source.lang.swift.ref.protocol,
6056+
key.name: "SignedInteger",
6057+
key.usr: "s:Ps13SignedInteger"
6058+
},
6059+
{
6060+
key.kind: source.lang.swift.ref.protocol,
6061+
key.name: "Comparable",
6062+
key.usr: "s:Ps10Comparable"
6063+
},
6064+
{
6065+
key.kind: source.lang.swift.ref.protocol,
6066+
key.name: "Equatable",
6067+
key.usr: "s:Ps9Equatable"
6068+
}
6069+
]
60536070
},
60546071
{
60556072
key.kind: source.lang.swift.decl.var.global,

test/SourceKit/DocSupport/doc_source_file.swift.response

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2586,9 +2586,19 @@
25862586
key.fully_annotated_decl: "<decl.typealias><syntaxtype.keyword>typealias</syntaxtype.keyword> <decl.name>Element</decl.name> = <ref.struct usr=\"s:Si\">Int</ref.struct></decl.typealias>",
25872587
key.conforms: [
25882588
{
2589-
key.kind: source.lang.swift.ref.associatedtype,
2590-
key.name: "Element",
2591-
key.usr: "s:P8__main__5Prot27Element"
2589+
key.kind: source.lang.swift.ref.protocol,
2590+
key.name: "SignedInteger",
2591+
key.usr: "s:Ps13SignedInteger"
2592+
},
2593+
{
2594+
key.kind: source.lang.swift.ref.protocol,
2595+
key.name: "Comparable",
2596+
key.usr: "s:Ps10Comparable"
2597+
},
2598+
{
2599+
key.kind: source.lang.swift.ref.protocol,
2600+
key.name: "Equatable",
2601+
key.usr: "s:Ps9Equatable"
25922602
}
25932603
]
25942604
},

0 commit comments

Comments
 (0)