You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sema: When diagnosing required explicit availability, skip members of extensions that have been declared explicitly unavailable. The existing logic only checked for an unavailable attr in the direct attributes of the decl.
Copy file name to clipboardExpand all lines: test/attr/require_explicit_availability.swift
+36Lines changed: 36 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,11 @@ public struct S { // expected-warning {{public declarations should have an avail
7
7
publicfunc method(){}
8
8
}
9
9
10
+
@available(macOS, unavailable)
11
+
publicstructUnavailableStruct{
12
+
publicfunc okMethod(){}
13
+
}
14
+
10
15
publicfunc foo(){bar()} // expected-warning {{public declarations should have an availability attribute when building with -require-explicit-availability}} {{1-1=@available(macOS 10.10, *)\n}}
11
16
12
17
@usableFromInline
@@ -41,10 +46,25 @@ public func +(lhs: S, rhs: S) -> S { } // expected-warning {{public declarations
41
46
42
47
publicenumE{} // expected-warning {{public declarations should have an availability attribute when building with -require-explicit-availability}} {{1-1=@available(macOS 10.10, *)\n}}
43
48
49
+
@available(macOS, unavailable)
50
+
publicenumUnavailableEnum{
51
+
case caseOk
52
+
}
53
+
44
54
publicclassC{} // expected-warning {{public declarations should have an availability attribute when building with -require-explicit-availability}} {{1-1=@available(macOS 10.10, *)\n}}
45
55
56
+
@available(macOS, unavailable)
57
+
publicclassUnavailableClass{
58
+
publicfunc okMethod(){}
59
+
}
60
+
46
61
publicprotocolP{} // expected-warning {{public declarations should have an availability attribute when building with -require-explicit-availability}} {{1-1=@available(macOS 10.10, *)\n}}
47
62
63
+
@available(macOS, unavailable)
64
+
publicprotocolUnavailableProto{
65
+
func requirementOk()
66
+
}
67
+
48
68
privateprotocolPrivateProto{}
49
69
50
70
extensionS{ // expected-warning {{public declarations should have an availability attribute when building with -require-explicit-availability}} {{1-1=@available(macOS 10.10, *)\n}}
@@ -56,11 +76,19 @@ extension S {
56
76
publicfunc okWhenTheExtensionHasAttribute(){}
57
77
}
58
78
79
+
@available(macOS, unavailable)
80
+
extensionS{
81
+
publicfunc okWhenTheExtensionIsUnavailable(){}
82
+
}
83
+
59
84
extensionS{
60
85
internalfunc dontWarnWithoutPublicMembers(){}
61
86
privatefunc dontWarnWithoutPublicMembers1(){}
62
87
}
63
88
89
+
// An empty extension should be ok.
90
+
extensionS{}
91
+
64
92
extensionS:P{ // expected-warning {{public declarations should have an availability attribute when building with -require-explicit-availability}} {{1-1=@available(macOS 10.10, *)\n}}
65
93
}
66
94
@@ -96,6 +124,9 @@ public var publicVar = S() // expected-warning {{public declarations should have
96
124
@available(macOS 10.10,*)
97
125
publicvarpublicVarOk=S()
98
126
127
+
@available(macOS, unavailable)
128
+
publicvarunavailablePublicVarOk=S()
129
+
99
130
publicvar(a, b)=(S(),S()) // expected-warning {{public declarations should have an availability attribute when building with -require-explicit-availability}} {{1-1=@available(macOS 10.10, *)\n}}
100
131
101
132
@available(macOS 10.10,*)
@@ -112,6 +143,11 @@ public var implicitGetOk: S {
112
143
returnS()
113
144
}
114
145
146
+
@available(macOS, unavailable)
147
+
publicvarunavailableImplicitGetOk:S{
148
+
returnS()
149
+
}
150
+
115
151
publicvarcomputed:S{ // expected-warning {{public declarations should have an availability attribute when building with -require-explicit-availability}} {{1-1=@available(macOS 10.10, *)\n}}
0 commit comments