Skip to content

Commit 104cd47

Browse files
committed
Determine concurrency diagnostic behavior based on conformance context.
When determining whether to warn, error, or be silent about concurrency-related issues detected between a protocol requirement and its witness, decide based on the context of the conformance rather than based on the context of the witness. Fixes rdar://88205585.
1 parent 1fc78f9 commit 104cd47

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

lib/Sema/TypeCheckProtocol.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2908,7 +2908,7 @@ bool ConformanceChecker::checkActorIsolation(
29082908
bool isCrossActor = false;
29092909
bool witnessIsUnsafe = false;
29102910
DiagnosticBehavior behavior = SendableCheckContext(
2911-
witness->getInnermostDeclContext()).defaultDiagnosticBehavior();
2911+
Conformance->getDeclContext()).defaultDiagnosticBehavior();
29122912
Type witnessGlobalActor;
29132913
switch (auto witnessRestriction =
29142914
ActorIsolationRestriction::forDeclaration(

test/Concurrency/actor_isolation_unsafe.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,16 @@ struct S3_P1: P1 {
2929
nonisolated func onMainActor() { }
3030
}
3131

32+
struct S4_P1_quitely: P1 {
33+
@SomeGlobalActor func onMainActor() { }
34+
}
35+
36+
@SomeGlobalActor
3237
struct S4_P1: P1 {
3338
@SomeGlobalActor func onMainActor() { } // expected-warning{{instance method 'onMainActor()' isolated to global actor 'SomeGlobalActor' can not satisfy corresponding requirement from protocol 'P1' isolated to global actor 'MainActor'}}
3439
}
3540

41+
3642
@MainActor(unsafe)
3743
protocol P2 {
3844
func f() // expected-note{{calls to instance method 'f()' from outside of its actor context are implicitly asynchronous}}

test/decl/class/actor/global_actor_conformance.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-typecheck-verify-swift -disable-availability-checking
1+
// RUN: %target-typecheck-verify-swift -disable-availability-checking -warn-concurrency
22
// REQUIRES: concurrency
33

44
actor SomeActor { }

0 commit comments

Comments
 (0)