Skip to content

Java2Swift: Separate "reference type" from "value type" mappings #131

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

DougGregor
Copy link
Member

While in general we want to map Java classes to Swift value types, there are places where we need to work with the class type, such as generic parameters. Identify those places where it is okay to bridge to a value type (e.g., parameters, results, field types) and do so.

Elsewhere, use the Swift type that directly wraps the Java class. For example, when dealing with superclasses or with generic arguments to Java generic classes.

As part of this, provide a class mapping for java.lang.String (as JavaString) and Java arrays (as the non-generic JavaArray) so we have a way to refer to such types in positions that cannot use the value type. Test this out with a few APIs that need it.

Fixes issue #128.

While in general we want to map Java classes to Swift value types,
there are places where we need to work with the class type, such as
generic parameters. Identify those places where it is okay to bridge
to a value type (e.g., parameters, results, field types) and do so.

Elsewhere, use the Swift type that directly wraps the Java class. For
example, when dealing with superclasses or with generic arguments to
Java generic classes.

As part of this, provide a class mapping for java.lang.String (as
JavaString) and Java arrays (as the non-generic JavaArray) so we have a
way to refer to such types in positions that cannot use the value type.
Test this out with a few APIs that need it.

Fixes issue swiftlang#128.
@DougGregor DougGregor merged commit 83c7b0f into swiftlang:main Oct 29, 2024
11 checks passed
@DougGregor DougGregor deleted the java2swift-reference-vs-value-types branch October 29, 2024 00:47
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