Skip to content

[6.2][Concurrency] Forego Sendable checking if conversion doesn't change t… #82675

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 1 commit into from
Jul 1, 2025
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
8 changes: 8 additions & 0 deletions lib/Sema/TypeCheckConcurrency.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2865,6 +2865,14 @@ namespace {
break;

case FunctionTypeIsolation::Kind::GlobalActor:
// If the isolation is the same it means that conversion
// covers loss of `@Sendable` or some other attribute and
// we don't need Sendable checking because there is no
// boundary crossing here.
if (fromIsolation.getGlobalActorType()->isEqual(
toIsolation.getGlobalActorType()))
break;

diagnoseNonSendableParametersAndResult(
toFnType, version::Version::getFutureMajorLanguageVersion());
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ public struct S<T> {
}
}

public class NS {}

public func testNoIsolation(_: @escaping (NS) -> Void) {}

//--- Client.swift
import API

Expand Down Expand Up @@ -164,3 +168,14 @@ func testMembers<X>(v: X, s: S<X>, fn: @escaping @MainActor (X) -> Int) {
// CHECK-NEXT: [[EXEC:%.*]] = extract_executor [[MAIN_ACTOR_ACCESS]] : $MainActor
// CHECK: [[CHECK_EXEC_REF:%.*]] = function_ref @$ss22_checkExpectedExecutor14_filenameStart01_D6Length01_D7IsASCII5_line9_executoryBp_BwBi1_BwBetF
// CHECK-NEXT: {{.*}} = apply [[CHECK_EXEC_REF]]({{.*}}, [[EXEC]])

@MainActor
class Test {
@Sendable func compute(_: NS) {}
// expected-warning@-1 {{main actor-isolated synchronous instance method 'compute' cannot be marked as '@Sendable'; this is an error in the Swift 6 language mode}}

func test() {
// Triggers loss of @Sendable and actor isolation erasure at the same time
testNoIsolation(compute)
}
}