Skip to content

JNI: fix non-compiling async thunks for protocol boxes and generic types - #905

Open
Flatout73 wants to merge 1 commit into
swiftlang:mainfrom
Flatout73:bugfix/dollar-sign
Open

JNI: fix non-compiling async thunks for protocol boxes and generic types#905
Flatout73 wants to merge 1 commit into
swiftlang:mainfrom
Flatout73:bugfix/dollar-sign

Conversation

@Flatout73

@Flatout73 Flatout73 commented Aug 23, 2026

Copy link
Copy Markdown

Motivation

Async methods in JNI mode capture self into the Task via nonisolated(unsafe)
bindings. The capture always referenced <param>$, but that binding only exists for
class/actor lowering (.extractSwiftValue). Protocol boxes load self into
<param>Existential$, and generic-Self downcalls render inside the opener extension
where selfTypePointer is never bound — so the generated Swift referenced unbound
identifiers and failed to compile.

Changes

  • Capture the binding the self lowering actually produced: <param>$ for
    classes/actors, <param>Existential$ for protocol boxes.
  • Stop capturing the type-metadata parameter; the opener thunk neither receives
    nor binds it, and the task body never uses it.

Testing

New JNIAsyncSelfCaptureTests pin the generated captures for all three self
shapes (class, protocol box, generic class); the generic and protocol tests fail
without this change. Full test suite passes (654 tests).

🤖 Fixed with help of Claude Code

#865

@Flatout73 Flatout73 changed the title Bugfix/dollar sign JNI: fix non-compiling async thunks for protocol boxes and generic types Aug 23, 2026
@Flatout73
Flatout73 marked this pull request as ready for review August 23, 2026 16:12
@Flatout73
Flatout73 requested a review from ktoso as a code owner August 23, 2026 16:12
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