Skip to content

🍒[5.10][Distributed] Allow overloads with different types; mangling can handle it #69596

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 4 commits into from
Nov 9, 2023

Conversation

ktoso
Copy link
Contributor

@ktoso ktoso commented Nov 2, 2023

Description: We too aggressively prevented overloads; The code's intention was to prevent overloads ONLY on the effects of a function (async / throws), since it complicates the relationship with thunks. Overloads ARE allowed and work just fine, so this patch fixes the too naive type system checking.
Risk: Low, loosens up the too restrictive checks made on distributed funcs. The mangling scheme can handle these with no problem.
Reward: Adopters are able to write APIs in the style they're used to, e.g. "distributed func received(SomeEvent)" and "distributed func received(OtherEvent)".
Impact: Small; Only distributed function overloads are affected.
Review by: @xedin @slavapestov
Testing: CI testing; added tests to cover the situation.
Original PR: #69595
Radar: rdar://117818281

@ktoso ktoso requested a review from a team as a code owner November 2, 2023 03:51
@ktoso
Copy link
Contributor Author

ktoso commented Nov 2, 2023

@swift-ci please test

@ktoso
Copy link
Contributor Author

ktoso commented Nov 6, 2023

@swift-ci please test

@ktoso
Copy link
Contributor Author

ktoso commented Nov 6, 2023

@swift-ci please test

lib/AST/Decl.cpp Outdated
// Note also, that overloading on throws is already illegal anyway.
if (sig1.IsDistributed || sig2.IsDistributed) {
if (sig1.IsAsyncFunction != sig2.IsAsyncFunction)
return true;
Copy link
Member

Choose a reason for hiding this comment

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

I do not believe this is correct; if one of them is distributed, and mismatch on async, we should fall through to check the names below, not determine that they are always conflicting. They might have different argument names entirely.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you, I’ll check and fix that

Copy link
Contributor

@xedin xedin Nov 7, 2023

Choose a reason for hiding this comment

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

Oh it’s too early, I should have taken a closer look, sorry!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you both for reviewing! 🙏

Copy link
Contributor Author

@ktoso ktoso Nov 7, 2023

Choose a reason for hiding this comment

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

adjustment here #69688 though I must be blind, was not able to get the described overload scenarios fail 🤔

@ktoso
Copy link
Contributor Author

ktoso commented Nov 7, 2023

@swift-ci please test

@ktoso
Copy link
Contributor Author

ktoso commented Nov 8, 2023

@swift-ci please test Windows

@ktoso ktoso enabled auto-merge November 8, 2023 01:50
@ktoso ktoso requested a review from DougGregor November 8, 2023 09:43
@ktoso ktoso merged commit 805d5c5 into swiftlang:release/5.10 Nov 9, 2023
@ktoso ktoso deleted the pick-wip-distributed-overloads branch November 9, 2023 22:20
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.

3 participants