Skip to content

Fix availability inference for unownedExecutor. #39445

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
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
13 changes: 8 additions & 5 deletions lib/Sema/DerivedConformanceActor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,14 @@ static ValueDecl *deriveActor_unownedExecutor(DerivedConformance &derived) {
if (property->getFormalAccess() == AccessLevel::Open)
property->overwriteAccess(AccessLevel::Public);

// Clone any @available attributes from UnownedSerialExecutor.
// Really, though, the whole actor probably needs to be marked as
// unavailable.
for (auto attr: executorDecl->getAttrs().getAttributes<AvailableAttr>())
property->getAttrs().add(attr->clone(ctx, /*implicit*/true));
// Infer availability.
SmallVector<const Decl *, 2> asAvailableAs;
asAvailableAs.push_back(executorDecl);
if (auto enclosingDecl = property->getInnermostDeclWithAvailability())
asAvailableAs.push_back(enclosingDecl);

AvailabilityInference::applyInferredAvailableAttrs(
property, asAvailableAs, ctx);

auto getter =
derived.addGetterToReadOnlyDerivedProperty(property, executorType);
Expand Down
8 changes: 8 additions & 0 deletions test/Concurrency/concurrency_availability.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,11 @@ actor A { } // expected-error{{concurrency is only available in}}
// Allow this without any availability for Historical Reasons.
public func swift_deletedAsyncMethodError() async {
}

// Ensure that our synthesis of the actor's unownedExecutor does not cause
// availability errors.
@available(macOS 12.0, *)
struct S {
actor A {
}
}