Skip to content

AST: Correct inferred availability attributes on synthesized declarations #63361

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
10 changes: 2 additions & 8 deletions lib/AST/Decl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -398,14 +398,8 @@ void Decl::forEachAttachedMacro(MacroRole role,
}

const Decl *Decl::getInnermostDeclWithAvailability() const {
const Decl *enclosingDecl = this;
// Find the innermost enclosing declaration with an @available annotation.
while (enclosingDecl != nullptr) {
if (enclosingDecl->getAttrs().hasAttribute<AvailableAttr>())
return enclosingDecl;

enclosingDecl = enclosingDecl->getDeclContext()->getAsDecl();
}
if (auto attrAndDecl = getSemanticAvailableRangeAttr())
return attrAndDecl.value().second;

return nullptr;
}
Expand Down
10 changes: 10 additions & 0 deletions test/Concurrency/concurrency_availability.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// RUN: %target-swift-frontend -parse-stdlib -target x86_64-apple-macosx10.14 -typecheck -verify %s
// RUN: %target-swift-frontend -parse-stdlib -target x86_64-apple-macosx11 -typecheck %s
// RUN: %target-swift-frontend -parse-stdlib -target x86_64-apple-macosx12 -typecheck %s -DTARGET_MACOS_12
// REQUIRES: OS=macosx

func f() async { } // expected-error{{concurrency is only available in}}
Expand All @@ -19,3 +20,12 @@ struct S {
actor A {
}
}

// The synthesized unownedExecutor inside this extension on S should inherit
// availability from S to avoid availability errors.
#if TARGET_MACOS_12
extension S {
actor A2 {
}
}
#endif