Skip to content

Commit e8df655

Browse files
author
Nathan Hawes
authored
Merge pull request #31536 from nathawes/doc-info-availability-catalyst-fix-5.3
[5.3][SourceKit] Report macCatalyst availability as macCatalyst rather than iOS
2 parents 2df2675 + 6daccf2 commit e8df655

6 files changed

+236
-1
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/// Some doc
2+
@available(iOS, deprecated)
3+
public func isAlwaysDeprecated_iOS() {}
4+
5+
@available(macCatalyst, deprecated)
6+
public func isAlwaysDeprecated_catalyst() {}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/// Some doc
2+
@available(iOS, deprecated)
3+
public func isAlwaysDeprecated_iOS() {}
4+
5+
@available(macCatalyst, deprecated)
6+
public func isAlwaysDeprecated_catalyst() {}
7+
8+
@available(iOS, deprecated: 20.0)
9+
public func deprecatedInFutureVersion_iOS() {}
10+
11+
@available(macCatalyst, deprecated: 20.0)
12+
public func deprecatedInFutureVersion_catalyst() {}
13+
14+
@available(iOS, deprecated: 1.0)
15+
public func deprecatedInPastVersion_iOS() {}
16+
17+
@available(macCatalyst, deprecated: 1.0)
18+
public func deprecatedInPastVersion_catalyst() {}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// RUN: %empty-directory(%t.mod)
2+
// RUN: %target-swift-frontend -emit-module -o %t.mod/availability.swiftmodule %S/Inputs/availability_maccatalyst.swift -parse-as-library -emit-module-doc-path %t.mod/availability.swiftdoc
3+
// RUN: %sourcekitd-test -req=doc-info -module availability -- -target %target-triple -I %t.mod | %FileCheck %s
4+
5+
// CHECK: key.name: "isAlwaysDeprecated_catalyst()",
6+
// CHECK: key.attributes: [
7+
// CHECK-NEXT: {
8+
// CHECK-NEXT: key.kind: source.lang.swift.attribute.availability,
9+
// CHECK-NEXT: key.platform: source.availability.platform.maccatalyst,
10+
// CHECK-NEXT: key.is_deprecated: 1
11+
// CHECK-NEXT: }
12+
// CHECK-NEXT: ]
13+
14+
// CHECK: key.name: "isAlwaysDeprecated_iOS()",
15+
// CHECK: key.attributes: [
16+
// CHECK-NEXT: {
17+
// CHECK-NEXT: key.kind: source.lang.swift.attribute.availability,
18+
// CHECK-NEXT: key.platform: source.availability.platform.ios,
19+
// CHECK-NEXT: key.is_deprecated: 1
20+
// CHECK-NEXT: }
21+
// CHECK-NEXT: ]
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// REQUIRES: OS=maccatalyst
2+
3+
// RUN: %empty-directory(%t.mod)
4+
// RUN: %swift -emit-module -target x86_64-apple-ios13.1-macabi -o %t.mod/availability.swiftmodule %S/Inputs/availability_maccatalyst_is_deprecated.swift -parse-as-library -emit-module-doc-path %t.mod/availability.swiftdoc
5+
// RUN: %sourcekitd-test -req=doc-info -module availability -- -target x86_64-apple-ios13.1-macabi -I %t.mod > %t.response
6+
// RUN: %diff -u %s.response %t.response
Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
import SwiftOnoneSupport
2+
3+
func deprecatedInFutureVersion_catalyst()
4+
5+
func deprecatedInFutureVersion_iOS()
6+
7+
func deprecatedInPastVersion_catalyst()
8+
9+
func deprecatedInPastVersion_iOS()
10+
11+
func isAlwaysDeprecated_catalyst()
12+
13+
func isAlwaysDeprecated_iOS()
14+
15+
16+
[
17+
{
18+
key.kind: source.lang.swift.syntaxtype.keyword,
19+
key.offset: 0,
20+
key.length: 6
21+
},
22+
{
23+
key.kind: source.lang.swift.syntaxtype.identifier,
24+
key.offset: 7,
25+
key.length: 17
26+
},
27+
{
28+
key.kind: source.lang.swift.syntaxtype.keyword,
29+
key.offset: 26,
30+
key.length: 4
31+
},
32+
{
33+
key.kind: source.lang.swift.syntaxtype.identifier,
34+
key.offset: 31,
35+
key.length: 34
36+
},
37+
{
38+
key.kind: source.lang.swift.syntaxtype.keyword,
39+
key.offset: 69,
40+
key.length: 4
41+
},
42+
{
43+
key.kind: source.lang.swift.syntaxtype.identifier,
44+
key.offset: 74,
45+
key.length: 29
46+
},
47+
{
48+
key.kind: source.lang.swift.syntaxtype.keyword,
49+
key.offset: 107,
50+
key.length: 4
51+
},
52+
{
53+
key.kind: source.lang.swift.syntaxtype.identifier,
54+
key.offset: 112,
55+
key.length: 32
56+
},
57+
{
58+
key.kind: source.lang.swift.syntaxtype.keyword,
59+
key.offset: 148,
60+
key.length: 4
61+
},
62+
{
63+
key.kind: source.lang.swift.syntaxtype.identifier,
64+
key.offset: 153,
65+
key.length: 27
66+
},
67+
{
68+
key.kind: source.lang.swift.syntaxtype.keyword,
69+
key.offset: 184,
70+
key.length: 4
71+
},
72+
{
73+
key.kind: source.lang.swift.syntaxtype.identifier,
74+
key.offset: 189,
75+
key.length: 27
76+
},
77+
{
78+
key.kind: source.lang.swift.syntaxtype.keyword,
79+
key.offset: 220,
80+
key.length: 4
81+
},
82+
{
83+
key.kind: source.lang.swift.syntaxtype.identifier,
84+
key.offset: 225,
85+
key.length: 22
86+
}
87+
]
88+
[
89+
{
90+
key.kind: source.lang.swift.decl.function.free,
91+
key.name: "deprecatedInFutureVersion_catalyst()",
92+
key.usr: "s:12availability34deprecatedInFutureVersion_catalystyyF",
93+
key.offset: 26,
94+
key.length: 41,
95+
key.fully_annotated_decl: "<decl.function.free><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>deprecatedInFutureVersion_catalyst</decl.name>()</decl.function.free>",
96+
key.attributes: [
97+
{
98+
key.kind: source.lang.swift.attribute.availability,
99+
key.platform: source.availability.platform.maccatalyst,
100+
key.deprecated: "20.0"
101+
}
102+
]
103+
},
104+
{
105+
key.kind: source.lang.swift.decl.function.free,
106+
key.name: "deprecatedInFutureVersion_iOS()",
107+
key.usr: "s:12availability29deprecatedInFutureVersion_iOSyyF",
108+
key.offset: 69,
109+
key.length: 36,
110+
key.fully_annotated_decl: "<decl.function.free><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>deprecatedInFutureVersion_iOS</decl.name>()</decl.function.free>",
111+
key.attributes: [
112+
{
113+
key.kind: source.lang.swift.attribute.availability,
114+
key.platform: source.availability.platform.ios,
115+
key.deprecated: "20.0"
116+
}
117+
]
118+
},
119+
{
120+
key.kind: source.lang.swift.decl.function.free,
121+
key.name: "deprecatedInPastVersion_catalyst()",
122+
key.usr: "s:12availability32deprecatedInPastVersion_catalystyyF",
123+
key.offset: 107,
124+
key.length: 39,
125+
key.fully_annotated_decl: "<decl.function.free><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>deprecatedInPastVersion_catalyst</decl.name>()</decl.function.free>",
126+
key.attributes: [
127+
{
128+
key.kind: source.lang.swift.attribute.availability,
129+
key.platform: source.availability.platform.maccatalyst,
130+
key.deprecated: "1.0"
131+
}
132+
],
133+
key.is_deprecated: 1
134+
},
135+
{
136+
key.kind: source.lang.swift.decl.function.free,
137+
key.name: "deprecatedInPastVersion_iOS()",
138+
key.usr: "s:12availability27deprecatedInPastVersion_iOSyyF",
139+
key.offset: 148,
140+
key.length: 34,
141+
key.fully_annotated_decl: "<decl.function.free><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>deprecatedInPastVersion_iOS</decl.name>()</decl.function.free>",
142+
key.attributes: [
143+
{
144+
key.kind: source.lang.swift.attribute.availability,
145+
key.platform: source.availability.platform.ios,
146+
key.deprecated: "1.0"
147+
}
148+
],
149+
key.is_deprecated: 1
150+
},
151+
{
152+
key.kind: source.lang.swift.decl.function.free,
153+
key.name: "isAlwaysDeprecated_catalyst()",
154+
key.usr: "s:12availability27isAlwaysDeprecated_catalystyyF",
155+
key.offset: 184,
156+
key.length: 34,
157+
key.fully_annotated_decl: "<decl.function.free><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>isAlwaysDeprecated_catalyst</decl.name>()</decl.function.free>",
158+
key.attributes: [
159+
{
160+
key.kind: source.lang.swift.attribute.availability,
161+
key.platform: source.availability.platform.maccatalyst,
162+
key.is_deprecated: 1
163+
}
164+
],
165+
key.is_deprecated: 1
166+
},
167+
{
168+
key.kind: source.lang.swift.decl.function.free,
169+
key.name: "isAlwaysDeprecated_iOS()",
170+
key.usr: "s:12availability22isAlwaysDeprecated_iOSyyF",
171+
key.doc.full_as_xml: "<Function><Name>isAlwaysDeprecated_iOS()</Name><USR>s:12availability22isAlwaysDeprecated_iOSyyF</USR><Declaration>@available(iOS, deprecated)\nfunc isAlwaysDeprecated_iOS()</Declaration><CommentParts><Abstract><Para>Some doc</Para></Abstract></CommentParts></Function>",
172+
key.offset: 220,
173+
key.length: 29,
174+
key.fully_annotated_decl: "<decl.function.free><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>isAlwaysDeprecated_iOS</decl.name>()</decl.function.free>",
175+
key.attributes: [
176+
{
177+
key.kind: source.lang.swift.attribute.availability,
178+
key.platform: source.availability.platform.ios,
179+
key.is_deprecated: 1
180+
}
181+
],
182+
key.is_deprecated: 1
183+
}
184+
]

tools/SourceKit/lib/SwiftLang/SwiftDocSupport.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ static void reportAttributes(ASTContext &Ctx,
630630
case PlatformKind::iOS:
631631
PlatformUID = PlatformIOS; break;
632632
case PlatformKind::macCatalyst:
633-
PlatformUID = PlatformIOS; break;
633+
PlatformUID = PlatformMacCatalyst; break;
634634
case PlatformKind::OSX:
635635
PlatformUID = PlatformOSX; break;
636636
case PlatformKind::tvOS:

0 commit comments

Comments
 (0)