Skip to content

jextract/jni: Handle single-element tuples correctly#725

Merged
ktoso merged 2 commits intoswiftlang:mainfrom
sidepelican:single_tuple
May 1, 2026
Merged

jextract/jni: Handle single-element tuples correctly#725
ktoso merged 2 commits intoswiftlang:mainfrom
sidepelican:single_tuple

Conversation

@sidepelican
Copy link
Copy Markdown
Contributor

Code generation fails when a single-element tuple is used. In Swift, (T) is semantically identical to T, so attempting to access it via .0 causes a compiler error.

1375 |   let element_0_jni$ = tupleResult$.0.getJNILocalRefValue(in: environment)
     |                                     `- error: value of type 'String' has no member '0'

I've updated the generator to treat tuples with a single element as a single unwrapped value instead of a tuple.

@sidepelican sidepelican requested a review from ktoso as a code owner April 27, 2026 03:57
Copy link
Copy Markdown
Collaborator

@ktoso ktoso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, happy to drop the Tuple1

@ktoso ktoso merged commit 2ae35b6 into swiftlang:main May 1, 2026
64 checks passed
@sidepelican sidepelican deleted the single_tuple branch May 1, 2026 14:40
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