BridgeJS: Support nested @JS types inside structs and classes#735
Merged
BridgeJS: Support nested @JS types inside structs and classes#735
Conversation
cd3f8dc to
fbe3640
Compare
fbe3640 to
6eb6668
Compare
kateinoigakukun
approved these changes
Apr 30, 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 #667.
@JSstructs and classes nested inside other@JSstructs or classes now generate correct Swift code with fully qualified type names and unique ABI symbols.The import side (
@JSClass/@JSGettermacros) already handles nested types correctly — the Swift compiler provides the fully qualified type for extension generation. The bug was on the export side (@JSattribute), where the codegen pipeline produced broken code for nested types.Previously, a nested type like
User.Statswould generate code referencing bareStats— wrong Swift name, wrong ABI symbols, and potential collisions with top-level types of the same name.Before:
After:
1.
computeSwiftCallName— now walks parentStructDeclSyntaxandClassDeclSyntaxin addition toEnumDeclSyntax, producing"User.Stats"instead of"Stats".2.
computeParentTypeNamespace+effectiveNamespace— computes the parent struct/class path and merges it with the resolved enum namespace for ABI name uniqueness.3. Struct/class visitors — use effective namespace when creating
ExportedStruct/ExportedClass, keeping keys and ABI names collision-free.Existing enum namespace nesting continues to work unchanged.
Tests:
NestedType.swiftexport-side test fixture with codegen + link snapshotsnestedJSClassStructmacro test confirming the import side already works