Skip to content

Java2Swift: Account for covariant overrides so we don't have duplicates #121

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
merged 2 commits into from
Oct 28, 2024

Conversation

DougGregor
Copy link
Member

When we see methods with the same name and parameter types but different
result types, check whether the result types are related and only keep
the more specialized method.

When we see methods with the same name and parameter types but different
result types, check whether the result types are related and only keep
the more specialized method.
Comment on lines -28 to -30
@JavaMethod
public func clone() throws -> JavaObject?

Copy link
Member Author

Choose a reason for hiding this comment

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

This method is subsumed by the covariant method above it, hence its removal.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Gotcha, makes sense +1

@DougGregor
Copy link
Member Author

It's a little hard to test the effect of this pull request in isolation, because we don't have a good way to test "does not emit this code", but I've marked where in the generated sources we drop a method because it's been subsumed by a covariant override.

Copy link
Collaborator

@ktoso ktoso left a comment

Choose a reason for hiding this comment

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

Looks good, nice to capture it in a "collector" 👍

@DougGregor DougGregor merged commit f5cbcdf into swiftlang:main Oct 28, 2024
11 checks passed
@DougGregor DougGregor deleted the covariant-overrides branch October 28, 2024 06:46
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