@@ -163,8 +163,28 @@ public struct ImportTS {
163163 }
164164 )
165165 )
166+ } else if case . nullable ( . swiftProtocol , _) = param . type , context == . exportSwift {
167+ body . write ( " let \( pattern ) : (Int32, Int32) " )
168+ body . write ( " if let \( param . name ) { " )
169+ body . indent {
170+ body . write (
171+ " \( pattern ) = (1, ( \( param . name ) as! _BridgedSwiftProtocolExportable).bridgeJSLowerAsProtocolReturn()) "
172+ )
173+ }
174+ body . write ( " } else { " )
175+ body . indent {
176+ body . write ( " \( pattern ) = (0, 0) " )
177+ }
178+ body . write ( " } " )
166179 } else {
167- let initializerExpr = ExprSyntax ( " \( raw : param . name ) .bridgeJSLowerParameter() " )
180+ let initializerExpr : ExprSyntax
181+ if case . swiftProtocol = param . type , context == . exportSwift {
182+ initializerExpr = ExprSyntax (
183+ " ( \( raw : param . name ) as! _BridgedSwiftProtocolExportable).bridgeJSLowerAsProtocolReturn() "
184+ )
185+ } else {
186+ initializerExpr = ExprSyntax ( " \( raw : param . name ) .bridgeJSLowerParameter() " )
187+ }
168188
169189 if loweringInfo . loweredParameters . isEmpty {
170190 stackLoweringStmts . insert ( " let _ = \( initializerExpr ) " , at : 0 )
@@ -817,7 +837,12 @@ extension BridgeType {
817837 case . swiftHeapObject :
818838 return LoweringParameterInfo ( loweredParameters : [ ( " pointer " , . pointer ) ] )
819839 case . swiftProtocol :
820- throw BridgeJSCoreError ( " swiftProtocol is not supported in imported signatures " )
840+ switch context {
841+ case . importTS :
842+ throw BridgeJSCoreError ( " swiftProtocol is not supported in imported signatures " )
843+ case . exportSwift :
844+ return LoweringParameterInfo ( loweredParameters : [ ( " objectId " , . i32 ) ] )
845+ }
821846 case . caseEnum :
822847 switch context {
823848 case . importTS :
@@ -891,7 +916,12 @@ extension BridgeType {
891916 case . swiftHeapObject :
892917 return LiftingReturnInfo ( valueToLift : . pointer )
893918 case . swiftProtocol :
894- throw BridgeJSCoreError ( " swiftProtocol is not supported in imported signatures " )
919+ switch context {
920+ case . importTS :
921+ throw BridgeJSCoreError ( " swiftProtocol is not supported in imported signatures " )
922+ case . exportSwift :
923+ return LiftingReturnInfo ( valueToLift : . i32 )
924+ }
895925 case . caseEnum :
896926 switch context {
897927 case . importTS :
0 commit comments