Skip to content

jextract/jni/ffm: Prevent Swift overloads by parameter names causing duplicate names in Java, add suffix to names#629

Merged
ktoso merged 2 commits intoswiftlang:mainfrom
ktoso:wip-clemo97-overload-conflicts
Mar 18, 2026
Merged

jextract/jni/ffm: Prevent Swift overloads by parameter names causing duplicate names in Java, add suffix to names#629
ktoso merged 2 commits intoswiftlang:mainfrom
ktoso:wip-clemo97-overload-conflicts

Conversation

@ktoso
Copy link
Collaborator

@ktoso ktoso commented Mar 18, 2026

Swift allows method overloading via parameter labels (e.g. takeValue(a:) and takeValue(b:)), but both produce the same Java signature. This adds a DuplicateNames analysis that detects actual conflicts and appends parameter label suffixes (e.g. takeValueA, takeValueB) only when needed. Non-overloaded methods keep their clean names.

From the original PR this moved on to do camelCase since it's more idiomatic for Java users, and I also made the same thing work in JNI and FFM modes.

This takes over #544 to complete it as author was not responsive over the few months.

Disclaimer: AI assisted tests and aligning FFM and JNI modes to do the same handling.

Swift allows method overloading via parameter labels (e.g. takeValue(a:)
and takeValue(b:)), but both produce the same Java signature. This adds
a DuplicateNames analysis that detects actual conflicts and appends
parameter label suffixes (e.g. takeValue_a, takeValue_b) only when
needed. Non-overloaded methods keep their clean names.

Co-authored-by: clemo97 <lumumbaclement@gmail.com>
@ktoso ktoso changed the title Wip clemo97 overload conflicts Prevent Swift overloads by parameter names causing duplicate names in Java, add suffix to names Mar 18, 2026
@ktoso ktoso changed the title Prevent Swift overloads by parameter names causing duplicate names in Java, add suffix to names jextract/jni/ffm: Prevent Swift overloads by parameter names causing duplicate names in Java, add suffix to names Mar 18, 2026
@ktoso ktoso force-pushed the wip-clemo97-overload-conflicts branch from 5f17361 to 49d2f26 Compare March 18, 2026 05:51
@ktoso ktoso merged commit 77f7d1f into swiftlang:main Mar 18, 2026
61 checks passed
@ktoso ktoso deleted the wip-clemo97-overload-conflicts branch March 18, 2026 06:03
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