From f6bd3ef33d03195ed8f7742de92038109d817dbf Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Fri, 23 Jan 2026 10:33:22 +0800 Subject: [PATCH 1/2] BridgeJS: Relax SwiftSyntax version constraint to support 602 and 603 --- Package.swift | 2 +- .../Sources/BridgeJSCore/ExportSwift.swift | 11 +++++++ .../Sources/BridgeJSCore/ImportTS.swift | 32 ++++++++++++++----- 3 files changed, 36 insertions(+), 9 deletions(-) diff --git a/Package.swift b/Package.swift index 7dac6fbae..a513ec406 100644 --- a/Package.swift +++ b/Package.swift @@ -37,7 +37,7 @@ let package = Package( .plugin(name: "BridgeJSCommandPlugin", targets: ["BridgeJSCommandPlugin"]), ], dependencies: [ - .package(url: "https://github.com/swiftlang/swift-syntax", "600.0.0"..<"601.0.0") + .package(url: "https://github.com/swiftlang/swift-syntax", "600.0.0"..<"603.0.0") ], targets: [ .target( diff --git a/Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift b/Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift index b9b9e0634..376a36edc 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift @@ -2528,9 +2528,20 @@ struct ClosureCodegen { capture: ClosureCaptureClauseSyntax( leftSquare: .leftSquareToken(), items: ClosureCaptureListSyntax { + #if canImport(SwiftSyntax602) + ClosureCaptureSyntax( + name: .identifier("", presence: .missing), initializer: InitializerClauseSyntax( + equal: .equalToken(presence: .missing), + nil, + value: ExprSyntax("callback") + ), + trailingTrivia: nil + ) + #else ClosureCaptureSyntax( expression: ExprSyntax("callback") ) + #endif }, rightSquare: .rightSquareToken() ), diff --git a/Plugins/BridgeJS/Sources/BridgeJSCore/ImportTS.swift b/Plugins/BridgeJS/Sources/BridgeJSCore/ImportTS.swift index 675708c45..6e153ed83 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSCore/ImportTS.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSCore/ImportTS.swift @@ -734,16 +734,32 @@ enum SwiftCodePattern { /// Builds the standard @_expose and @_cdecl attributes for WebAssembly-exposed functions static func buildExposeAttributes(abiName: String) -> AttributeListSyntax { return AttributeListSyntax { + #if canImport(SwiftSyntax602) + let exposeAttrArgs = AttributeSyntax.Arguments.argumentList( + [ + LabeledExprSyntax(label: nil, expression: DeclReferenceExprSyntax(baseName: "wasm")), + LabeledExprSyntax(label: nil, expression: StringLiteralExprSyntax(content: abiName)), + ] + ) + let cdeclAttrArgs = AttributeSyntax.Arguments.argumentList( + [ + LabeledExprSyntax(label: nil, expression: StringLiteralExprSyntax(content: abiName)), + ] + ) + #else + let exposeAttrArgs = AttributeSyntax.Arguments.exposeAttributeArguments( + ExposeAttributeArgumentsSyntax( + language: .identifier("wasm"), + comma: .commaToken(), + cxxName: StringLiteralExprSyntax(content: abiName) + ) + ) + let cdeclAttrArgs = AttributeSyntax.Arguments.string(StringLiteralExprSyntax(content: abiName)) + #endif AttributeSyntax( attributeName: IdentifierTypeSyntax(name: .identifier("_expose")), leftParen: .leftParenToken(), - arguments: .exposeAttributeArguments( - ExposeAttributeArgumentsSyntax( - language: .identifier("wasm"), - comma: .commaToken(), - cxxName: StringLiteralExprSyntax(content: abiName) - ) - ), + arguments: exposeAttrArgs, rightParen: .rightParenToken() ) .with(\.trailingTrivia, .newline) @@ -751,7 +767,7 @@ enum SwiftCodePattern { AttributeSyntax( attributeName: IdentifierTypeSyntax(name: .identifier("_cdecl")), leftParen: .leftParenToken(), - arguments: .string(StringLiteralExprSyntax(content: abiName)), + arguments: cdeclAttrArgs, rightParen: .rightParenToken() ) .with(\.trailingTrivia, .newline) From 000ed105b1909ca8b99a46cdec3d494715962ca0 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Fri, 23 Jan 2026 12:50:11 +0000 Subject: [PATCH 2/2] Fix formatting --- Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift | 3 ++- Plugins/BridgeJS/Sources/BridgeJSCore/ImportTS.swift | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift b/Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift index 376a36edc..bb51ebafc 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift @@ -2530,7 +2530,8 @@ struct ClosureCodegen { items: ClosureCaptureListSyntax { #if canImport(SwiftSyntax602) ClosureCaptureSyntax( - name: .identifier("", presence: .missing), initializer: InitializerClauseSyntax( + name: .identifier("", presence: .missing), + initializer: InitializerClauseSyntax( equal: .equalToken(presence: .missing), nil, value: ExprSyntax("callback") diff --git a/Plugins/BridgeJS/Sources/BridgeJSCore/ImportTS.swift b/Plugins/BridgeJS/Sources/BridgeJSCore/ImportTS.swift index 6e153ed83..0ca301b68 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSCore/ImportTS.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSCore/ImportTS.swift @@ -743,7 +743,7 @@ enum SwiftCodePattern { ) let cdeclAttrArgs = AttributeSyntax.Arguments.argumentList( [ - LabeledExprSyntax(label: nil, expression: StringLiteralExprSyntax(content: abiName)), + LabeledExprSyntax(label: nil, expression: StringLiteralExprSyntax(content: abiName)) ] ) #else