BridgeJS: Support optional @JSClass as exported function parameters#754
Merged
krodak merged 2 commits intoJun 9, 2026
swiftwasm:mainswiftwasm/JavaScriptKit:mainfrom
PassiveLogic:kr/fix-optional-jsclass-paramPassiveLogic/JavaScriptKit:kr/fix-optional-jsclass-paramCopy head branch name to clipboard
Merged
BridgeJS: Support optional @JSClass as exported function parameters#754krodak merged 2 commits intoswiftwasm:mainswiftwasm/JavaScriptKit:mainfrom PassiveLogic:kr/fix-optional-jsclass-paramPassiveLogic/JavaScriptKit:kr/fix-optional-jsclass-paramCopy head branch name to clipboard
krodak merged 2 commits into
swiftwasm:mainswiftwasm/JavaScriptKit:mainfrom
PassiveLogic:kr/fix-optional-jsclass-paramPassiveLogic/JavaScriptKit:kr/fix-optional-jsclass-paramCopy head branch name to clipboard
Conversation
Member
|
Sorry, I'm still reviewing this, so please give me some more time 🙇 |
kateinoigakukun
requested changes
Jun 9, 2026
5dbbd02 to
c93a031
Compare
kateinoigakukun
approved these changes
Jun 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Fixes #751. A
@JSexported function taking (or returning) an optional@JSClasssuch asJSAbortSignal?failed to compile withno exact matches in call to static method 'bridgeJSLiftParameter'forOptional<JSAbortSignal>.Optional
jsObject(incl.@JSClass) parameters now use the direct(isSome, objId)ABI in both directions, matching plainOptional<JSObject>and exported@JS classparameters; only return values use the stack ABI.1. Export parameters: use the direct ABI.
ExportSwiftno longer special-cases.nullable(.jsObject), so exported parameters lift viaOptional<T>.bridgeJSLiftParameter(isSome, value). Adds the missingOptional<_JSBridgedClass>.bridgeJSLiftParameter(isSome, objId)andbridgeJSLowerReturn()so optional@JSClassvalues round-trip as both parameters and return values.2. Import parameters: align to the direct ABI.
loweringParameterInfoalready lowered optionaljsObjectimport parameters as direct(isSome, value), but the JS lift still popped the object id off the stack that Swift never pushed, throwingReferenceError: Attempted to use invalid reference undefinedfor a non-nil value. The JS lift now reads the object id directly, matching the extern.A new
optionalParameterUsesStackABIkeeps the stack ABI only for the return direction of optionaljsObject.Tests
@JSClassdirectly as an exported function parameter and return value (present andnullcases), plus snapshot coverage for optionalJSObject?and@JSClass?.JSObject?into an imported JS function (present andnullcases), plus updated snapshot coverage for the optional@JSClass?import parameter.