Skip to content

jextract/jni: Support generic types within Optional and Tuple#657

Merged
ktoso merged 12 commits intoswiftlang:mainfrom
sidepelican:generic_complex
Apr 1, 2026
Merged

jextract/jni: Support generic types within Optional and Tuple#657
ktoso merged 12 commits intoswiftlang:mainfrom
sidepelican:generic_complex

Conversation

@sidepelican
Copy link
Copy Markdown
Contributor

Currently, code generation is incorrect when generic types are used in combination with other complex types.
This PR fixes this for Optional and Tuple types.

Key Changes

Previously, when a native function used indirect, the downcall was printed in JavaNativeConversionStep.
This design required calling .print(.placeholder) during the initial Step of the conversion flow.

However, detecting whether a step is the "first" one is difficult during flow construction. To simplify the logic, I have moved the downcall printing to JNISwift2JavaGenerator.

@sidepelican sidepelican requested a review from ktoso as a code owner March 31, 2026 01:44
@ktoso
Copy link
Copy Markdown
Collaborator

ktoso commented Mar 31, 2026

Ok happy enough with it, once tests pass

@sidepelican
Copy link
Copy Markdown
Contributor Author

It looks like there’s an issue with 32-bit Android.
It might take some effort to resolve, and since I don't have any more time today, so I’ll work on it tomorrow.

@ktoso
Copy link
Copy Markdown
Collaborator

ktoso commented Mar 31, 2026

Thank you!

@sidepelican
Copy link
Copy Markdown
Contributor Author

I've confirmed that this is an existing issue related to Int? and not related to this PR.
Fixing it is outside the scope of this PR, so I'll update the sample code to use another pattern instead.

@ktoso
Copy link
Copy Markdown
Collaborator

ktoso commented Apr 1, 2026

Sounds good, thank you!

@ktoso ktoso merged commit 9c44625 into swiftlang:main Apr 1, 2026
61 checks passed
@sidepelican sidepelican deleted the generic_complex branch April 1, 2026 06:15
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.

2 participants