Skip to content

Commit 0275637

Browse files
committed
AST: Disallow @available attributes on generic parameters
This was a no-op and it doesn't make sense in the current model.
1 parent 8fd29a5 commit 0275637

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

include/swift/AST/Attr.def

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,7 @@ DECL_ATTR(_silgen_name, SILGenName,
120120
0)
121121
DECL_ATTR(available, Available,
122122
OnAbstractFunction | OnGenericType | OnVar | OnSubscript | OnEnumElement |
123-
OnExtension | OnGenericTypeParam |
124-
AllowMultipleAttributes | LongAttribute |
123+
OnExtension | AllowMultipleAttributes | LongAttribute |
125124
ABIStableToAdd | ABIStableToRemove | APIStableToAdd | APIStableToRemove,
126125
1)
127126
CONTEXTUAL_SIMPLE_DECL_ATTR(final, Final,

test/attr/attr_availability.swift

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -257,11 +257,6 @@ func TextOutputStreamTest(message: String, to: inout TextOutputStream) {
257257
print(message, &to) // expected-error {{'print' is unavailable: Please use the 'to' label for the target stream: 'print((...), to: &...)'}}
258258
}
259259

260-
// expected-note@+1{{'T' has been explicitly marked unavailable here}}
261-
struct UnavailableGenericParam<@available(*, unavailable, message: "nope") T> {
262-
func f(t: T) { } // expected-error{{'T' is unavailable: nope}}
263-
}
264-
265260

266261
struct DummyType {}
267262

@@ -1119,3 +1114,6 @@ func testBadRename() {
11191114
_ = BadRename(from: 5, to: 17) // expected-warning{{'init(from:to:step:)' is deprecated: replaced by 'init(range:step:)'}}
11201115
// expected-note@-1{{use 'init(range:step:)' instead}}
11211116
}
1117+
1118+
struct AvailableGenericParam<@available(*, deprecated) T> {}
1119+
// expected-error@-1 {{'@available' attribute cannot be applied to this declaration}}

0 commit comments

Comments
 (0)