Skip to content

[Concurrency] Diagnose Sendable violations in captures of local functions. #68693

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 2 commits into from
Sep 22, 2023

Conversation

hborla
Copy link
Member

@hborla hborla commented Sep 22, 2023

Previously, the actor isolation checker only checked local captures of closures. This change correctly diagnoses the following code:

class NonSendable {}

func testLocalCaptures() {
  let ns = NonSendable()

  @Sendable func a2() -> NonSendable {
    return ns // error:  capture of 'ns' with non-sendable type 'NonSendable' in a `@Sendable` local function
  }
}

(Note that this PR currently contains the change for #68685)

Resolves rdar://113293502

@hborla
Copy link
Member Author

hborla commented Sep 22, 2023

@swift-ci please smoke test

@hborla hborla merged commit d6483ae into swiftlang:main Sep 22, 2023
@hborla hborla deleted the non-sendable-local-captures branch September 22, 2023 14:43
@slavapestov
Copy link
Contributor

Nice cleanup!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants