Skip to content

Commit 48c5c83

Browse files
authored
Merge pull request #39445 from DougGregor/availability-inference-unowned-executor
2 parents 71eedb1 + 04edbc3 commit 48c5c83

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

lib/Sema/DerivedConformanceActor.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,14 @@ static ValueDecl *deriveActor_unownedExecutor(DerivedConformance &derived) {
154154
if (property->getFormalAccess() == AccessLevel::Open)
155155
property->overwriteAccess(AccessLevel::Public);
156156

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

163166
auto getter =
164167
derived.addGetterToReadOnlyDerivedProperty(property, executorType);

test/Concurrency/concurrency_availability.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,11 @@ actor A { } // expected-error{{concurrency is only available in}}
1111
// Allow this without any availability for Historical Reasons.
1212
public func swift_deletedAsyncMethodError() async {
1313
}
14+
15+
// Ensure that our synthesis of the actor's unownedExecutor does not cause
16+
// availability errors.
17+
@available(macOS 12.0, *)
18+
struct S {
19+
actor A {
20+
}
21+
}

0 commit comments

Comments
 (0)