Skip to content

Determine concurrency diagnostic behavior based on conformance context. #41076

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
2 changes: 1 addition & 1 deletion lib/Sema/TypeCheckProtocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2908,7 +2908,7 @@ bool ConformanceChecker::checkActorIsolation(
bool isCrossActor = false;
bool witnessIsUnsafe = false;
DiagnosticBehavior behavior = SendableCheckContext(
witness->getInnermostDeclContext()).defaultDiagnosticBehavior();
Conformance->getDeclContext()).defaultDiagnosticBehavior();
Type witnessGlobalActor;
switch (auto witnessRestriction =
ActorIsolationRestriction::forDeclaration(
Expand Down
6 changes: 6 additions & 0 deletions test/Concurrency/actor_isolation_unsafe.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,16 @@ struct S3_P1: P1 {
nonisolated func onMainActor() { }
}

struct S4_P1_quitely: P1 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
struct S4_P1_quitely: P1 {
struct S4_P1_quietly: P1 {

@SomeGlobalActor func onMainActor() { }
}

@SomeGlobalActor
struct S4_P1: P1 {
@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'}}
}


@MainActor(unsafe)
protocol P2 {
func f() // expected-note{{calls to instance method 'f()' from outside of its actor context are implicitly asynchronous}}
Expand Down
2 changes: 1 addition & 1 deletion test/decl/class/actor/global_actor_conformance.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %target-typecheck-verify-swift -disable-availability-checking
// RUN: %target-typecheck-verify-swift -disable-availability-checking -warn-concurrency
// REQUIRES: concurrency

actor SomeActor { }
Expand Down