Skip to content

jextract/ffm: Fix TranslatedParameter to hold a single JavaParameter#759

Merged
ktoso merged 2 commits into
swiftlang:mainfrom
sidepelican:signle_param_ffm
May 19, 2026
Merged

jextract/ffm: Fix TranslatedParameter to hold a single JavaParameter#759
ktoso merged 2 commits into
swiftlang:mainfrom
sidepelican:signle_param_ffm

Conversation

@sidepelican
Copy link
Copy Markdown
Contributor

This is a minor refactoring to fix the property type of javaParameters in the FFM-side TranslatedParameter.

Currently, it is defined as an array. However, I believe this is incorrect.
This type represents the Java function interface that the user interacts with, meaning it is not yet "lowered". Therefore, the parameter count should always match the number of Swift arguments.

In practice, there wasn't a place in the codebase where multiple parameters were actually being used.

This PR changes the property to hold a single JavaParameter.
This aligns the implementation with the JNI side.

@sidepelican sidepelican requested a review from ktoso as a code owner May 19, 2026 03:57
* }
*/
public static void receiveDataProtocol(Data dat, Optional<Data> dat2) {
public static void receiveDataProtocol(Data dat, java.util.Optional<Data> dat2) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nice side effect, FQN are better

/// Array because one Swift parameter can be mapped to multiple parameters.
var javaParameters: [JavaParameter]
/// Java parameter mapped to the Swift parameter.
var parameter: JavaParameter
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

👍 Yeah I think that's right, lowering would explode it into multiple if necessary

@ktoso ktoso merged commit 673d8c9 into swiftlang:main May 19, 2026
73 checks passed
@sidepelican sidepelican deleted the signle_param_ffm branch May 19, 2026 05: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