Skip to content

[cxx-interop] Do not import arithmetic operators with rvalue reference parameters #80763

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 1 commit into from
Apr 14, 2025

Conversation

egorzhdan
Copy link
Contributor

Currently those operators are imported with a consuming: label, which isn't valid in Swift.

We could just remove the label from these parameters, but that introduces a source breakage due to name lookup ambiguity.

So, to avoid ambiguity, let's not import such operators into Swift.

rdar://149020099

…e parameters

Currently those operators are imported with a `consuming:` label, which isn't valid in Swift.

We could just remove the label from these parameters, but that introduces a source breakage due to name lookup ambiguity.

So, to avoid ambiguity, let's not import such operators into Swift.

rdar://149020099
Copy link
Contributor

@j-hui j-hui 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 to me!

Just to make sure I understand this correctly: it's not source-breaking to simply remove these because an operator with a consuming: label doesn't really make any sense in the first place. Is that right?

Not for this patch, but I'm also wondering if you have thoughts on how we might support these operators in the future?

Copy link
Contributor

@Xazax-hun Xazax-hun left a comment

Choose a reason for hiding this comment

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

I am not sure how could we import these in the future without ambiguity other than coming up with some not too ergonomic naming convention and import them as regular functions like __addConsumingFirstNonConsumingSecond.

@egorzhdan
Copy link
Contributor Author

I guess in the future we can theoretically import these operators iff there is no overload with lvalue reference parameters. But I'm not sure if it's common to have an rvalue overload but no lvalue overload for these operators.

@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test

@egorzhdan egorzhdan merged commit 6a6380b into main Apr 14, 2025
3 checks passed
@egorzhdan egorzhdan deleted the egorzhdan/rvalue-arg-operator branch April 14, 2025 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ interop Feature: Interoperability with C++
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants