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) {
2016
2016
if (isolation == overriddenIsolation)
2017
2017
return ;
2018
2018
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
+
2019
2025
// Isolation mismatch. Diagnose it.
2020
2026
value->diagnose (
2021
2027
diag::actor_isolation_override_mismatch, isolation,
Original file line number Diff line number Diff line change @@ -2739,7 +2739,11 @@ bool ConformanceChecker::checkActorIsolation(
2739
2739
2740
2740
// If the witness has a global actor but the requirement does not, we have
2741
2741
// 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 ()) {
2743
2747
witness->diagnose (
2744
2748
diag::global_actor_isolated_witness, witness->getDescriptiveKind (),
2745
2749
witness->getName (), witnessGlobalActor, Proto->getName ());
Original file line number Diff line number Diff line change 3
3
// REQUIRES: objc_interop
4
4
// REQUIRES: concurrency
5
5
import Foundation
6
+ import ObjectiveC
6
7
import ObjCConcurrency
7
8
8
9
// Conform via async method
@@ -51,3 +52,22 @@ extension C5: ConcurrentProtocol {
51
52
completionHandler ? ( " hello " )
52
53
}
53
54
}
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