Skip to content

[4.2 EARLY] Revert "'@available' without an OS is ignored on extensions" warning #16324

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions include/swift/AST/DiagnosticsSema.def
Original file line number Diff line number Diff line change
Expand Up @@ -3751,10 +3751,6 @@ WARNING(availability_query_useless_enclosing_scope, none,
NOTE(availability_query_useless_enclosing_scope_here, none,
"enclosing scope here", ())

WARNING(availability_extension_platform_agnostic, none,
"'@available' without an OS is ignored on extensions; "
"apply the attribute to each member instead", ())

ERROR(availability_global_script_no_potential,
none, "global variable cannot be marked potentially "
"unavailable with '@available' in script mode", ())
Expand Down
9 changes: 1 addition & 8 deletions lib/Sema/TypeCheckAttr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class AttributeEarlyChecker : public AttributeVisitor<AttributeEarlyChecker> {
bool visitDeclAttribute(DeclAttribute *A) = delete;

#define IGNORED_ATTR(X) void visit##X##Attr(X##Attr *) {}
IGNORED_ATTR(Available)
IGNORED_ATTR(CDecl)
IGNORED_ATTR(ClangImporterSynthesizedType)
IGNORED_ATTR(Convenience)
Expand Down Expand Up @@ -115,14 +116,6 @@ class AttributeEarlyChecker : public AttributeVisitor<AttributeEarlyChecker> {
IGNORED_ATTR(WeakLinked)
#undef IGNORED_ATTR

void visitAvailableAttr(AvailableAttr *attr) {
if (!isa<ExtensionDecl>(D))
return;
if (attr->hasPlatform())
return;
diagnoseAndRemoveAttr(attr, diag::availability_extension_platform_agnostic);
}

// @noreturn has been replaced with a 'Never' return type.
void visitNoReturnAttr(NoReturnAttr *attr) {
if (auto FD = dyn_cast<FuncDecl>(D)) {
Expand Down
7 changes: 0 additions & 7 deletions test/attr/attr_availability.swift
Original file line number Diff line number Diff line change
Expand Up @@ -809,13 +809,6 @@ rdar32526620_3(a: 42, b: .bar, c: "question")
// 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=}}


@available(*, unavailable) // expected-warning {{'@available' without an OS is ignored on extensions; apply the attribute to each member instead}} {{1-28=}}
extension DummyType {}

@available(*, deprecated) // expected-warning {{'@available' without an OS is ignored on extensions; apply the attribute to each member instead}} {{1-27=}}
extension DummyType {}


var deprecatedGetter: Int {
@available(*, deprecated) get { return 0 }
set {}
Expand Down
6 changes: 3 additions & 3 deletions test/attr/attr_availability_swift.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ extension TestStruct {
func doTheThing() {} // expected-note {{'doTheThing()' was introduced in Swift 400}}
}

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

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

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