Skip to content

jextract/jni: Propagate generic parameters to Case types of generic enums#765

Merged
ktoso merged 4 commits into
swiftlang:mainfrom
sidepelican:generic_enum_param
May 26, 2026
Merged

jextract/jni: Propagate generic parameters to Case types of generic enums#765
ktoso merged 4 commits into
swiftlang:mainfrom
sidepelican:generic_enum_param

Conversation

@sidepelican
Copy link
Copy Markdown
Contributor

This PR is the first step toward supporting the extraction of generic associated values from generic enum.

Currently, the generated Case types for generic enums do not carry generic parameters.
While this isn't causing immediate issues, these parameters will be necessary in the future when we want to extract generic associated values from the Case.

public sealed interface Case {
  // `Wrapped` is not usable from the static context
  record Some(Wrapped arg0) implements Case {}
  record None() implements Case {}
}

This PR focuses solely on propagating the generic parameters of the enum type down to its Case type.

During this work, I encountered and fixed an issue in wrap-java where translation was failing when a nested type's parent type was generic.


Note

I have loved contributing to swift-java for a half year, but unfortunately, I have run out of time to continue doing so.
While I will keep following the development of swift-java, I won't be able to actively contribute as I did before.

Thank you so much for all your valuable code reviews.

@sidepelican sidepelican requested a review from ktoso as a code owner May 23, 2026 09:07
Comment thread Tests/SwiftJavaToolLibTests/JavaTranslatorTests.swift Outdated
@ktoso
Copy link
Copy Markdown
Collaborator

ktoso commented May 23, 2026

Oh too bad to hear you won’t have more time contributing … maybe in some hobby time :-)

Thanks for all the contributions, it’s all accounted for very useful improvements!

@sidepelican
Copy link
Copy Markdown
Contributor Author

sidepelican commented May 26, 2026

It looked like the tests were hanging, but the root cause was that I had modified the name of the test below with good intentions.
This test didn't start with test~, meaning it wasn't being picked up by XCTest.

func translateGenericMethodParameters() async throws {

As it turns out, running this test recreates the JVM internally.
However, if other test cases have already been executed and a JVM instance already exists, it somehow deadlocks.

Since this deadlock is an unrelated issue to this PR, I am reverting the test name back to its original state.

@ktoso
Copy link
Copy Markdown
Collaborator

ktoso commented May 26, 2026

Thanks, looks good. We have a source break due to argument-parser source breaking, I'm fixing the build now and will re-run this #767

@ktoso ktoso closed this May 26, 2026
@ktoso ktoso reopened this May 26, 2026
@ktoso ktoso merged commit d2cb92e into swiftlang:main May 26, 2026
61 of 114 checks passed
@sidepelican sidepelican deleted the generic_enum_param branch May 26, 2026 07: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