Skip to content

reject unsupported tuple components#750

Open
nerzh wants to merge 1 commit into
swiftlang:mainfrom
nerzh:fix/unsupported-tuple
Open

reject unsupported tuple components#750
nerzh wants to merge 1 commit into
swiftlang:mainfrom
nerzh:fix/unsupported-tuple

Conversation

@nerzh
Copy link
Copy Markdown

@nerzh nerzh commented May 14, 2026

I noticed that jextract allowed multielement swift tuples in places where the JNI bridge later requires a concrete JavaBoxable type. Swift tuples cannot conform to protocols, so the generated code could fail to compile. I fixed it by rejecting unsupported tuple components during translation 🫣

ObertonWalletCore/destination/JExtractSwiftPlugin/Sources/BindingStore+SwiftJava.swift:24:41: error: type 'BindingStore.RawResponse' (aka '(requestId: UInt32, stringResponse: String, responseType: TSDKBindingResponseType, finished: Bool)') cannot conform to 'JavaBoxable' [#ProtocolTypeNonConformance]
22 | @_cdecl("Java_com_custwallet_core_BindingStore__00024getCompleteResponses__")
23 | public func Java_com_custwallet_core_BindingStore__00024getCompleteResponses__(environment: UnsafeMutablePointer<JNIEnv?>!, thisClass: jclass) -> jlong {
24 |   return BindingStore.completeResponses.dictionaryGetJNIValue(in: environment)
   |                                         |- error: type 'BindingStore.RawResponse' (aka '(requestId: UInt32, stringResponse: String, responseType: TSDKBindingResponseType, finished: Bool)') cannot conform to 'JavaBoxable' [#ProtocolTypeNonConformance]
   |                                         `- note: only concrete types such as structs, enums and classes can conform to protocols
25 | } // printCDecl(_:javaMethodName:parentName:parameters:resultType:_:) @ JExtractSwiftLib/JNISwift2JavaGenerator+SwiftThunkPrinting.swift:751
26 | 

/oberton-wallet-core/.build/checkouts/swift-java/Sources/SwiftJava/BridgedValues/JavaValue+Dictionary.swift:20:1: note: required by referencing instance method 'dictionaryGetJNIValue(in:)' on 'Dictionary' where 'Value' = 'BindingStore.RawResponse' (aka '(requestId: UInt32, stringResponse: String, responseType: TSDKBindingResponseType, finished: Bool)')
18 | // MARK: Dictionary extension for JNI bridging
19 | 
20 | extension Dictionary where Key: JavaBoxable & Hashable, Value: JavaBoxable {
   | `- note: required by referencing instance method 'dictionaryGetJNIValue(in:)' on 'Dictionary' where 'Value' = 'BindingStore.RawResponse' (aka '(requestId: UInt32, stringResponse: String, responseType: TSDKBindingResponseType, finished: Bool)')
21 |   /// Box this dictionary and return a jlong pointer for passing across JNI.
22 |   /// The dictionary is retained on the Swift heap; Java holds the pointer.

@nerzh nerzh requested a review from ktoso as a code owner May 14, 2026 19:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant