Skip to content

[major]: non-Sendable parameters#5

Merged
tayloraswift merged 1 commit into
masterfrom
non-Sendable-parameters
Jul 4, 2026
Merged

[major]: non-Sendable parameters#5
tayloraswift merged 1 commit into
masterfrom
non-Sendable-parameters

Conversation

@tayloraswift

Copy link
Copy Markdown
Member

No description provided.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request updates JavaScriptModule to support registering asynchronous callbacks that either run on the @MainActor (allowing non-Sendable parameters) or run nonisolated (requiring Sendable parameters). Feedback was provided to ensure that the closure passed to JSClosure.async in the @MainActor registration method is explicitly isolated to @MainActor to prevent compiler warnings or errors under Swift 6 strict concurrency when handling non-Sendable parameters.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

operation: @MainActor @escaping (repeat each T) async throws -> JSValue
) where repeat each T: LoadableFromJSValue {
self.metatype[symbol.id] = .object(
JSClosure.async {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

Under Swift 6 strict concurrency, passing non-Sendable parameters (each T) across isolation boundaries from a nonisolated context to the @MainActor operation closure will trigger compiler warnings or errors. Since the callback is registered to run on the @MainActor, the closure passed to JSClosure.async should be explicitly isolated to @MainActor as well. This ensures that argument extraction and the subsequent call to operation occur entirely on the main actor, preventing any unsafe crossing of isolation boundaries.

            JSClosure.async { @MainActor in

@tayloraswift tayloraswift merged commit 889913c into master Jul 4, 2026
8 checks passed
@tayloraswift tayloraswift deleted the non-Sendable-parameters branch July 4, 2026 05:07
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.

1 participant