Skip to content

[Distributed] Survive generics with Sendable requirement in executeDistributedTarget #41854

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

Closed
wants to merge 2 commits into from

Conversation

ktoso
Copy link
Contributor

@ktoso ktoso commented Mar 17, 2022

Since Sendable as any other @_marker protocol does not exist at runtime, we're not able (and DON'T HAVE TO) find a witness for it. The function we're to invoke does not expect a witness for those anyway.

I did not find a way to detect "oh, this was a marker protocol" so instead I provide a mode to ignore unknown kinds. We only use it in our code so there should be no risk to other existing code.

resolves rdar://90293494

@ktoso ktoso requested review from xedin and DougGregor March 17, 2022 10:29
@ktoso ktoso force-pushed the wip-generics-missing-witness branch from 7a2e0cf to ae36adb Compare March 17, 2022 10:31
@ktoso ktoso force-pushed the wip-generics-missing-witness branch from ae36adb to a249ccd Compare March 17, 2022 10:36
for (const auto &req : requirements) {
// Make sure we understand the requirement we're dealing with.
if (!req.hasKnownKind())
return TypeLookupError("unknown kind");
if (!req.hasKnownKind()) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

so the kind here ends up being some weird 24 for the Sendable requirement...
Since it has an unknown kind we can't really get the mangled name or protocol etc to check it in detail if it is the exact sendable.

But the same issue would happen with any other @_marker protocol I suppose...

@ktoso ktoso added AArch64 Linux distributed Feature → concurrency: distributed actor and removed AArch64 Linux labels Mar 17, 2022
@ktoso
Copy link
Contributor Author

ktoso commented Mar 17, 2022

@swift-ci please smoke test

Comment on lines +465 to +467
/// \param skipUnknownKinds If true, unknown requirement kinds will not be
/// reported as errors. This should used with care, and e.g. only to ignore
/// @_marker protocols at runtime, which cannot be checked at runtime.
Copy link
Member

Choose a reason for hiding this comment

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

In the future, should we consider a runtime representation that indicates the requirement came from a marker protocol? Having any representation at runtime sounds like it goes against the purpose of a marker protocol, but I guess that was unavoidable in this case?

Copy link
Member

@DougGregor DougGregor left a comment

Choose a reason for hiding this comment

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

Ignoring/skipping Sendable requirements at this level shouldn't be necessary. Rather, we shouldn't mangle the Sendable requirements at all, so we don't need to demangle them. ASTMangler has an option, AllowMarkerProtocols, that you can set to false so that the mangler skips over any marker protocols when it mangles.

Copy link
Member

@kavon kavon left a comment

Choose a reason for hiding this comment

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

This looks good to me. The only concern I had was with the mixing of concepts: "unknown kind" with "marker protocol". But, I don't currently know of any better way to implement this fix.

@xedin
Copy link
Contributor

xedin commented Mar 17, 2022

@DougGregor This is not going to be as easy as mangling, generic environment descriptor _checkGenericRequirements is given as an argument to accessible function, I need to figure out how to drop @_marker protocols from there as well.

@ktoso If you don't mind I'd like to take over fixing this issue.

@ktoso
Copy link
Contributor Author

ktoso commented Mar 17, 2022

I see... thanks a lot, that makes sense @DougGregor . Thanks for the help @xedin !

@xedin
Copy link
Contributor

xedin commented Mar 17, 2022

Replaced by #41871

@xedin xedin closed this Mar 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
distributed Feature → concurrency: distributed actor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants