Skip to content

Comments

jextract/jni: Refactor toString generation to use the standard method generation path#567

Merged
ktoso merged 4 commits intoswiftlang:mainfrom
sidepelican:tostring_thunk
Feb 24, 2026
Merged

jextract/jni: Refactor toString generation to use the standard method generation path#567
ktoso merged 4 commits intoswiftlang:mainfrom
sidepelican:tostring_thunk

Conversation

@sidepelican
Copy link
Contributor

Motivation

Currently, the implementations for toString and toDebugString methods are handled by dedicated, hardcoded logic.
However, these methods are fundamentally identical to standard function calls in terms of their underlying mechanism.

This inconsistency makes it difficult to maintain parity with other parts of the generator. Specifically, as I work on implementing support for function calls in generic type, I find myself having to write redundant specialized logic just for toString, which adds unnecessary complexity.

Changes

Treat toString and toDebugString as ImportedFunc.
This allows them to be processed through the general method generation path.

Note

While this change also affects FFM mode, it will currently be ignored because String return values are not yet supported in that mode.

@sidepelican sidepelican requested a review from ktoso as a code owner February 17, 2026 06:47
@sidepelican
Copy link
Contributor Author

I have addressed the feedback. Are there any remaining concerns ?

@ktoso ktoso changed the title Refactor toString generation to use the standard method generation path jextract/jni: Refactor toString generation to use the standard method generation path Feb 24, 2026
Copy link
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.

Looks fine now, thank you

@ktoso ktoso merged commit da7d0a5 into swiftlang:main Feb 24, 2026
48 of 50 checks passed
@ktoso
Copy link
Collaborator

ktoso commented Feb 24, 2026

Thank you!

@sidepelican
Copy link
Contributor Author

Thank you too! Happy to see this merged.

@sidepelican sidepelican deleted the tostring_thunk branch February 24, 2026 06:52
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.

3 participants