File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
Plugins/BridgeJS/Sources/BridgeJSCore Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -319,8 +319,19 @@ public class ExportSwift {
319319 func render( abiName: String ) -> DeclSyntax {
320320 let body : CodeBlockItemListSyntax
321321 if effects. isAsync {
322+ // Explicit closure type annotation needed when throws is present
323+ // so Swift infers throws(JSException) instead of throws(any Error)
324+ // See: https://github.com/swiftlang/swift/issues/76165
325+ let closureHead : String
326+ if effects. isThrows {
327+ let hasReturn = self . body. contains { $0. description. contains ( " return " ) }
328+ let ret = hasReturn ? " -> JSValue " : " "
329+ closureHead = " () async throws(JSException) \( ret) in "
330+ } else {
331+ closureHead = " "
332+ }
322333 body = """
323- let ret = JSPromise.async {
334+ let ret = JSPromise.async { \( raw : closureHead )
324335 \( CodeBlockItemListSyntax ( self . body) )
325336 }.jsObject
326337 return ret.bridgeJSLowerReturn()
You can’t perform that action at this time.
0 commit comments