BridgeJS: Diagnose unsupported protocol conformers before lowering - #812
Merged
krodak merged 1 commit intoSep 7, 2026
Merged
Conversation
kateinoigakukun
approved these changes
Sep 7, 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
Currently, a Swift type can conform to a
@JSprotocol and compile successfully, then trap when returned to JavaScript because it does not conform to_BridgedSwiftProtocolExportable:This PR addresses that:
1. Diagnose unsupported conformers
Use the existing type index to check conformances after the exported API is collected. Diagnose unsupported conformers when their protocol crosses from Swift to JavaScript, while preserving lift-only and unused-protocol cases. Check closure directions, property accessors, and extension-declared conformances, including exported classes from dependencies.
2. Explain failures outside the generator's scope
Replace forced casts in generated glue with
_bridgeJSUnwrapProtocolExportable. When a conformance cannot be checked during generation, the runtime failure names the concrete type, protocol, and supported alternatives instead of producing an opaque cast trap.Test Plan
./Utilities/format.swift./Utilities/bridge-js-generate.shnpm run check:bridgejs-dtsmake unittest SWIFT_SDK_ID=swift-6.3-RELEASE_wasm BUILD_SYSTEM=native