BridgeJS: Fix optionals build error with Embedded Swift#734
Open
krodak wants to merge 1 commit intoswiftwasm:mainfrom
Open
BridgeJS: Fix optionals build error with Embedded Swift#734krodak wants to merge 1 commit intoswiftwasm:mainfrom
krodak wants to merge 1 commit intoswiftwasm:mainfrom
Conversation
Remove @_spi(BridgeJS) from _BridgedAsOptional protocol and its Optional/JSUndefinedOr conformances so the conformances are visible in Embedded Swift mode. The underscore-prefixed protocol name already signals internal API, and all extension methods remain @_spi-gated. Fixes swiftwasm#689
2c8ad10 to
f21075c
Compare
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 #689 - BridgeJS-generated code using optionals fails to compile when targeting Embedded Swift with
cannot use conformance of 'Optional<Wrapped>' to '_BridgedAsOptional' here; the conformance is declared as SPI.The root cause is that
@_spi(BridgeJS)on the_BridgedAsOptionalprotocol declaration and itsOptionalconformance makes the entire conformance invisible in Embedded Swift, even when the consumer uses@_spi(BridgeJS) import JavaScriptKit. This appears to be an Embedded Swift compiler limitation where SPI-gated retroactive conformances on stdlib types are not resolved.The fix removes
@_spi(BridgeJS)from three places:_BridgedAsOptionalprotocol declarationOptional: _BridgedAsOptionalconformanceJSUndefinedOr: _BridgedAsOptionalconformanceThe underscore-prefixed protocol name already signals internal API, and all methods on protocol extensions remain
@_spi(BridgeJS)-gated, so there is no meaningful change to the public API surface.Verified locally:
swift-6.3-RELEASE_wasm-embedded) - previously failedswift-6.3-RELEASE_wasm) - no regressionmake unittest)