Skip to content

Commit 8f256ad

Browse files
committed
[Sema] Update diagnostic for required availability
1 parent 99d9beb commit 8f256ad

File tree

2 files changed

+26
-26
lines changed

2 files changed

+26
-26
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5750,8 +5750,8 @@ NOTE(availability_protocol_requirement_here, none,
57505750
"protocol requirement here", ())
57515751

57525752
WARNING(public_decl_needs_availability, none,
5753-
"public declarations should have an availability attribute when building "
5754-
"with -require-explicit-availability", ())
5753+
"public declarations should have an availability attribute "
5754+
"with an introduction version", ())
57555755

57565756
ERROR(attr_requires_decl_availability_for_platform,none,
57575757
"'%0' requires that %1 have explicit availability for %2",

test/attr/require_explicit_availability.swift

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
// RUN: %swiftc_driver -typecheck -parse-as-library -target %target-cpu-apple-macosx10.10 -Xfrontend -verify -require-explicit-availability -require-explicit-availability-target "macOS 10.10" %s
55

6-
public struct S { // expected-warning {{public declarations should have an availability attribute when building with -require-explicit-availability}}
6+
public struct S { // expected-warning {{public declarations should have an availability attribute with an introduction version}}
77
public func method() { }
88
}
99

@@ -12,10 +12,10 @@ public struct UnavailableStruct {
1212
public func okMethod() { }
1313
}
1414

15-
public func foo() { bar() } // expected-warning {{public declarations should have an availability attribute when building with -require-explicit-availability}} {{1-1=@available(macOS 10.10, *)\n}}
15+
public func foo() { bar() } // expected-warning {{public declarations should have an availability attribute with an introduction version}} {{1-1=@available(macOS 10.10, *)\n}}
1616

1717
@usableFromInline
18-
func bar() { } // expected-warning {{public declarations should have an availability attribute when building with -require-explicit-availability}} {{1-1=@available(macOS 10.10, *)\n}}
18+
func bar() { } // expected-warning {{public declarations should have an availability attribute with an introduction version}} {{1-1=@available(macOS 10.10, *)\n}}
1919

2020
@available(macOS 10.1, *)
2121
public func ok() { }
@@ -24,10 +24,10 @@ public func ok() { }
2424
public func unavailableOk() { }
2525

2626
@available(macOS, deprecated: 10.10)
27-
public func missingIntro() { } // expected-warning {{public declarations should have an availability attribute when building with -require-explicit-availability}} {{1-1=@available(macOS 10.10, *)\n}}
27+
public func missingIntro() { } // expected-warning {{public declarations should have an availability attribute with an introduction version}} {{1-1=@available(macOS 10.10, *)\n}}
2828

2929
@available(iOS 9.0, *)
30-
public func missingTargetPlatform() { } // expected-warning {{public declarations should have an availability attribute when building with -require-explicit-availability}} {{1-1=@available(macOS 10.10, *)\n}}
30+
public func missingTargetPlatform() { } // expected-warning {{public declarations should have an availability attribute with an introduction version}} {{1-1=@available(macOS 10.10, *)\n}}
3131

3232
func privateFunc() { }
3333

@@ -42,23 +42,23 @@ struct SOk {
4242
precedencegroup MediumPrecedence {}
4343
infix operator + : MediumPrecedence
4444

45-
public func +(lhs: S, rhs: S) -> S { } // expected-warning {{public declarations should have an availability attribute when building with -require-explicit-availability}} {{1-1=@available(macOS 10.10, *)\n}}
45+
public func +(lhs: S, rhs: S) -> S { } // expected-warning {{public declarations should have an availability attribute with an introduction version}} {{1-1=@available(macOS 10.10, *)\n}}
4646

47-
public enum E { } // expected-warning {{public declarations should have an availability attribute when building with -require-explicit-availability}} {{1-1=@available(macOS 10.10, *)\n}}
47+
public enum E { } // expected-warning {{public declarations should have an availability attribute with an introduction version}} {{1-1=@available(macOS 10.10, *)\n}}
4848

4949
@available(macOS, unavailable)
5050
public enum UnavailableEnum {
5151
case caseOk
5252
}
5353

54-
public class C { } // expected-warning {{public declarations should have an availability attribute when building with -require-explicit-availability}} {{1-1=@available(macOS 10.10, *)\n}}
54+
public class C { } // expected-warning {{public declarations should have an availability attribute with an introduction version}} {{1-1=@available(macOS 10.10, *)\n}}
5555

5656
@available(macOS, unavailable)
5757
public class UnavailableClass {
5858
public func okMethod() { }
5959
}
6060

61-
public protocol P { } // expected-warning {{public declarations should have an availability attribute when building with -require-explicit-availability}} {{1-1=@available(macOS 10.10, *)\n}}
61+
public protocol P { } // expected-warning {{public declarations should have an availability attribute with an introduction version}} {{1-1=@available(macOS 10.10, *)\n}}
6262

6363
@available(macOS, unavailable)
6464
public protocol UnavailableProto {
@@ -67,8 +67,8 @@ public protocol UnavailableProto {
6767

6868
private protocol PrivateProto { }
6969

70-
extension S { // expected-warning {{public declarations should have an availability attribute when building with -require-explicit-availability}} {{1-1=@available(macOS 10.10, *)\n}}
71-
public func warnForPublicMembers() { } // expected-warning {{public declarations should have an availability attribute when building with -require-explicit-availability}} {{3-3=@available(macOS 10.10, *)\n }}
70+
extension S { // expected-warning {{public declarations should have an availability attribute with an introduction version}} {{1-1=@available(macOS 10.10, *)\n}}
71+
public func warnForPublicMembers() { } // expected-warning {{public declarations should have an availability attribute with an introduction version}} {{3-3=@available(macOS 10.10, *)\n }}
7272
}
7373

7474
@available(macOS 10.1, *)
@@ -89,13 +89,13 @@ extension S {
8989
// An empty extension should be ok.
9090
extension S { }
9191

92-
extension S : P { // expected-warning {{public declarations should have an availability attribute when building with -require-explicit-availability}} {{1-1=@available(macOS 10.10, *)\n}}
92+
extension S : P { // expected-warning {{public declarations should have an availability attribute with an introduction version}} {{1-1=@available(macOS 10.10, *)\n}}
9393
}
9494

9595
extension S : PrivateProto {
9696
}
9797

98-
open class OpenClass { } // expected-warning {{public declarations should have an availability attribute when building with -require-explicit-availability}} {{1-1=@available(macOS 10.10, *)\n}}
98+
open class OpenClass { } // expected-warning {{public declarations should have an availability attribute with an introduction version}} {{1-1=@available(macOS 10.10, *)\n}}
9999

100100
private class PrivateClass { }
101101

@@ -119,22 +119,22 @@ extension spiStruct {
119119
public func spiExtensionMethod() {}
120120
}
121121

122-
public var publicVar = S() // expected-warning {{public declarations should have an availability attribute when building with -require-explicit-availability}} {{1-1=@available(macOS 10.10, *)\n}}
122+
public var publicVar = S() // expected-warning {{public declarations should have an availability attribute with an introduction version}} {{1-1=@available(macOS 10.10, *)\n}}
123123

124124
@available(macOS 10.10, *)
125125
public var publicVarOk = S()
126126

127127
@available(macOS, unavailable)
128128
public var unavailablePublicVarOk = S()
129129

130-
public var (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}}
130+
public var (a, b) = (S(), S()) // expected-warning {{public declarations should have an availability attribute with an introduction version}} {{1-1=@available(macOS 10.10, *)\n}}
131131

132132
@available(macOS 10.10, *)
133133
public var (c, d) = (S(), S())
134134

135135
public var _ = S() // expected-error {{global variable declaration does not bind any variables}}
136136

137-
public var implicitGet: S { // expected-warning {{public declarations should have an availability attribute when building with -require-explicit-availability}} {{1-1=@available(macOS 10.10, *)\n}}
137+
public var implicitGet: S { // expected-warning {{public declarations should have an availability attribute with an introduction version}} {{1-1=@available(macOS 10.10, *)\n}}
138138
return S()
139139
}
140140

@@ -148,19 +148,19 @@ public var unavailableImplicitGetOk: S {
148148
return S()
149149
}
150150

151-
public var computed: S { // expected-warning {{public declarations should have an availability attribute when building with -require-explicit-availability}} {{1-1=@available(macOS 10.10, *)\n}}
151+
public var computed: S { // expected-warning {{public declarations should have an availability attribute with an introduction version}} {{1-1=@available(macOS 10.10, *)\n}}
152152
get { return S() }
153153
set { }
154154
}
155155

156-
public var computedHalf: S { // expected-warning {{public declarations should have an availability attribute when building with -require-explicit-availability}} {{1-1=@available(macOS 10.10, *)\n}}
156+
public var computedHalf: S { // expected-warning {{public declarations should have an availability attribute with an introduction version}} {{1-1=@available(macOS 10.10, *)\n}}
157157
@available(macOS 10.10, *)
158158
get { return S() }
159159
set { }
160160
}
161161

162162
// FIXME the following warning is not needed.
163-
public var computedOk: S { // expected-warning {{public declarations should have an availability attribute when building with -require-explicit-availability}} {{1-1=@available(macOS 10.10, *)\n}}
163+
public var computedOk: S { // expected-warning {{public declarations should have an availability attribute with an introduction version}} {{1-1=@available(macOS 10.10, *)\n}}
164164
@available(macOS 10.10, *)
165165
get { return S() }
166166

@@ -174,7 +174,7 @@ public var computedOk1: S {
174174
set { }
175175
}
176176

177-
public class SomeClass { // expected-warning {{public declarations should have an availability attribute when building with -require-explicit-availability}} {{1-1=@available(macOS 10.10, *)\n}}
177+
public class SomeClass { // expected-warning {{public declarations should have an availability attribute with an introduction version}} {{1-1=@available(macOS 10.10, *)\n}}
178178
public init () {}
179179

180180
public subscript(index: String) -> Int {
@@ -183,13 +183,13 @@ public class SomeClass { // expected-warning {{public declarations should have a
183183
}
184184
}
185185

186-
extension SomeClass { // expected-warning {{public declarations should have an availability attribute when building with -require-explicit-availability}} {{1-1=@available(macOS 10.10, *)\n}}
187-
public convenience init(s : S) {} // expected-warning {{public declarations should have an availability attribute when building with -require-explicit-availability}} {{3-3=@available(macOS 10.10, *)\n }}
186+
extension SomeClass { // expected-warning {{public declarations should have an availability attribute with an introduction version}} {{1-1=@available(macOS 10.10, *)\n}}
187+
public convenience init(s : S) {} // expected-warning {{public declarations should have an availability attribute with an introduction version}} {{3-3=@available(macOS 10.10, *)\n }}
188188

189189
@available(macOS 10.10, *)
190190
public convenience init(s : SomeClass) {}
191191

192-
public subscript(index: Int) -> Int { // expected-warning {{public declarations should have an availability attribute when building with -require-explicit-availability}} {{3-3=@available(macOS 10.10, *)\n }}
192+
public subscript(index: Int) -> Int { // expected-warning {{public declarations should have an availability attribute with an introduction version}} {{3-3=@available(macOS 10.10, *)\n }}
193193
get { return 42; }
194194
set(newValue) { }
195195
}
@@ -206,5 +206,5 @@ public struct StructWithImplicitMembers { }
206206

207207
extension StructWithImplicitMembers: Hashable { }
208208
// expected-note @-1 {{add @available attribute to enclosing extension}}
209-
// expected-warning @-2 {{public declarations should have an availability attribute when building with -require-explicit-availability}}
209+
// expected-warning @-2 {{public declarations should have an availability attribute with an introduction version}}
210210
// expected-error @-3 {{'StructWithImplicitMembers' is only available in macOS 10.15 or newer}}

0 commit comments

Comments
 (0)