File tree Expand file tree Collapse file tree 3 files changed +31
-1
lines changed
test/decl/protocol/conforms Expand file tree Collapse file tree 3 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -2016,6 +2016,12 @@ void swift::checkOverrideActorIsolation(ValueDecl *value) {
20162016 if (isolation == overriddenIsolation)
20172017 return ;
20182018
2019+ // If the overridden declaration is from Objective-C with no actor annotation,
2020+ // and the overriding declaration has been placed in a global actor, allow it.
2021+ if (overridden->hasClangNode () && !overriddenIsolation &&
2022+ isolation.getKind () == ActorIsolation::GlobalActor)
2023+ return ;
2024+
20192025 // Isolation mismatch. Diagnose it.
20202026 value->diagnose (
20212027 diag::actor_isolation_override_mismatch, isolation,
Original file line number Diff line number Diff line change @@ -2739,7 +2739,11 @@ bool ConformanceChecker::checkActorIsolation(
27392739
27402740 // If the witness has a global actor but the requirement does not, we have
27412741 // an isolation error.
2742- if (witnessGlobalActor && !requirementGlobalActor) {
2742+ //
2743+ // However, we allow this case when the requirement was imported, because
2744+ // it might not have been annotated.
2745+ if (witnessGlobalActor && !requirementGlobalActor &&
2746+ !requirement->hasClangNode ()) {
27432747 witness->diagnose (
27442748 diag::global_actor_isolated_witness, witness->getDescriptiveKind (),
27452749 witness->getName (), witnessGlobalActor, Proto->getName ());
Original file line number Diff line number Diff line change 33// REQUIRES: objc_interop
44// REQUIRES: concurrency
55import Foundation
6+ import ObjectiveC
67import ObjCConcurrency
78
89// Conform via async method
@@ -51,3 +52,22 @@ extension C5: ConcurrentProtocol {
5152 completionHandler ? ( " hello " )
5253 }
5354}
55+
56+ // Global actors.
57+ actor class SomeActor { }
58+
59+ @globalActor
60+ struct SomeGlobalActor {
61+ static let shared = SomeActor ( )
62+ }
63+
64+ class C6 : ConcurrentProtocol {
65+ @SomeGlobalActor
66+ func askUser( toSolvePuzzle puzzle: String ) async throws -> String { " " }
67+
68+ func askUser( toJumpThroughHoop hoop: String ) async -> String { " hello " }
69+ }
70+
71+ class C7 : NSObject {
72+ @SomeGlobalActor override var description : String { " on an actor " }
73+ }
You can’t perform that action at this time.
0 commit comments