Merged
Conversation
We now support passing and returing labelled tuples like (a: Int, b: Stirng) etc. This is important for being able to quickly port over code from swift to Java using the same libraries as we don't have to special case the labelled tuples and move them over to positional use. These ad hoc tuple types are printed per method. They would conflict if you use the same shape twice in a method right now... I'm not seeing much of that use so ignored it for now. The new tuples inherit from TupleN so Java code can just use them as positional when necessary, also for passing them along to other methods. The change is large because I also cleaned up type printing, I think printing full qualified type names is good here, better nor risk clashes.
ktoso
commented
Apr 2, 2026
| // TODO: When we support typed throws on Swift side we'll want to throw the right type here instead | ||
| if translatedSignature.isThrowing { | ||
| throwsClauses.append(JavaType.swiftJavaErrorException.simpleClassName) | ||
| throwsClauses.append(JavaType.swiftJavaErrorException.className!) |
Collaborator
Author
There was a problem hiding this comment.
simpleClassName was crashing on misuse anyway
ktoso
commented
Apr 2, 2026
| swiftResult: SwiftResult, | ||
| loweredResult: LoweredResult | ||
| loweredResult: LoweredResult, | ||
| methodName: String |
Collaborator
Author
There was a problem hiding this comment.
we need the method name to form the adhoc types per method
ktoso
commented
Apr 2, 2026
|
|
||
| let wrappedValueResult = try translate( | ||
| swiftResult: SwiftResult(convention: .direct, type: swiftType), | ||
| methodName: "", |
Collaborator
Author
There was a problem hiding this comment.
Double check this one
ktoso
commented
Apr 2, 2026
|
|
||
| // Element names are embedded in the class name after "LabeledTuple_<baseName>_" | ||
| // We need to extract the last `arity` underscore-separated components | ||
| let parts = rawClassName.split(separator: "_") |
Collaborator
Author
There was a problem hiding this comment.
TODO: this is pretty horrible, we're getting the field names from the type name...
To make this nicer we need to intreoduce SwiftJavaType that wraps a JavaType since JavaType is just "pure" java types without additional context like this. That's quite a big refactor so we may want to do this but better to do separately...
ktoso
commented
Apr 2, 2026
| case .array(let element): | ||
| collectLabeledTuples(from: element, into: &result) | ||
| default: | ||
| break |
Collaborator
Author
There was a problem hiding this comment.
potentially more uses here...
5aa9fad to
9a4a431
Compare
9a4a431 to
0bfe36e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We now support passing and returing labelled tuples like (a: Int, b: Stirng) etc.
This is important for being able to quickly port over code from swift to Java using the same libraries as we don't have to special case the labelled tuples and move them over to positional use.
These ad hoc tuple types are printed per method.
They would conflict if you use the same shape twice in a method right now... I'm not seeing much of that use so ignored it for now.
The new tuples inherit from TupleN so Java code can just use them as positional when necessary, also for passing them along to other methods.
The change is large because I also cleaned up type printing, I think printing full qualified type names is good here, better nor risk clashes.