Skip to content

Commit 40c8975

Browse files
committed
Revert "'@available' without an OS is ignored on extensions" warning
This is still useful for the feature where deprecated declarations are allowed to be used within a context that's marked deprecated. There's probably a better balance to be found here, because marking the extension deprecated still does not mark all the members deprecated, but for now it still has an effect, and we shouldn't produce a warning for legitimately making use of that effect. The warning was added in f21d9f3, mostly as an opportunity "fix". https://bugs.swift.org/browse/SR-7577
1 parent d5b98a0 commit 40c8975

File tree

4 files changed

+4
-22
lines changed

4 files changed

+4
-22
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3758,10 +3758,6 @@ WARNING(availability_query_useless_enclosing_scope, none,
37583758
NOTE(availability_query_useless_enclosing_scope_here, none,
37593759
"enclosing scope here", ())
37603760

3761-
WARNING(availability_extension_platform_agnostic, none,
3762-
"'@available' without an OS is ignored on extensions; "
3763-
"apply the attribute to each member instead", ())
3764-
37653761
ERROR(availability_global_script_no_potential,
37663762
none, "global variable cannot be marked potentially "
37673763
"unavailable with '@available' in script mode", ())

lib/Sema/TypeCheckAttr.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ class AttributeEarlyChecker : public AttributeVisitor<AttributeEarlyChecker> {
7070
bool visitDeclAttribute(DeclAttribute *A) = delete;
7171

7272
#define IGNORED_ATTR(X) void visit##X##Attr(X##Attr *) {}
73+
IGNORED_ATTR(Available)
7374
IGNORED_ATTR(CDecl)
7475
IGNORED_ATTR(ClangImporterSynthesizedType)
7576
IGNORED_ATTR(Convenience)
@@ -115,14 +116,6 @@ class AttributeEarlyChecker : public AttributeVisitor<AttributeEarlyChecker> {
115116
IGNORED_ATTR(WeakLinked)
116117
#undef IGNORED_ATTR
117118

118-
void visitAvailableAttr(AvailableAttr *attr) {
119-
if (!isa<ExtensionDecl>(D))
120-
return;
121-
if (attr->hasPlatform())
122-
return;
123-
diagnoseAndRemoveAttr(attr, diag::availability_extension_platform_agnostic);
124-
}
125-
126119
// @noreturn has been replaced with a 'Never' return type.
127120
void visitNoReturnAttr(NoReturnAttr *attr) {
128121
if (auto FD = dyn_cast<FuncDecl>(D)) {

test/attr/attr_availability.swift

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -809,13 +809,6 @@ rdar32526620_3(a: 42, b: .bar, c: "question")
809809
// expected-error@-1 {{'rdar32526620_3(a:b:c:)' has been replaced by instance method 'E_32526620.set(a:c:)'}} {{1-15=E_32526620.bar.set}} {{23-32=}}
810810

811811

812-
@available(*, unavailable) // expected-warning {{'@available' without an OS is ignored on extensions; apply the attribute to each member instead}} {{1-28=}}
813-
extension DummyType {}
814-
815-
@available(*, deprecated) // expected-warning {{'@available' without an OS is ignored on extensions; apply the attribute to each member instead}} {{1-27=}}
816-
extension DummyType {}
817-
818-
819812
var deprecatedGetter: Int {
820813
@available(*, deprecated) get { return 0 }
821814
set {}

test/attr/attr_availability_swift.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ extension TestStruct {
2929
func doTheThing() {} // expected-note {{'doTheThing()' was introduced in Swift 400}}
3030
}
3131

32-
@available(swift 400) // expected-warning {{'@available' without an OS is ignored on extensions; apply the attribute to each member instead}} {{1-23=}}
32+
@available(swift 400) // FIXME: This has no effect and should be complained about.
3333
extension TestStruct {
3434
func doAnotherThing() {}
3535
}
@@ -40,10 +40,10 @@ func testMemberAvailability() {
4040
TestStruct().doAnotherThing() // okay (for now)
4141
}
4242

43-
@available(swift 400) // expected-warning {{'@available' without an OS is ignored on extensions; apply the attribute to each member instead}} {{1-23=}}
43+
@available(swift 400) // FIXME: This has no effect and should be complained about.
4444
@available(macOS 10.11, *)
4545
extension TestStruct {}
4646

4747
@available(macOS 10.11, *)
48-
@available(swift 400) // expected-warning {{'@available' without an OS is ignored on extensions; apply the attribute to each member instead}} {{1-23=}}
48+
@available(swift 400) // FIXME: This has no effect and should be complained about.
4949
extension TestStruct {}

0 commit comments

Comments
 (0)