Skip to content

Sema: Relax distributed actor typechecking for swiftinterfaces #65431

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 26, 2023

Conversation

tshortli
Copy link
Contributor

Some decls that are expected to be synthesized for distributed actors are printed explicitly in swiftinterfaces so diagnostics and assertions need to take that possibility into account.

Resolves rdar://108533918

@tshortli
Copy link
Contributor Author

@swift-ci please test

@@ -68,7 +68,6 @@ static VarDecl*
if (!var->getInterfaceType()->isEqual(expectedType))
return nullptr;

assert(var->isSynthesized() && "Expected compiler synthesized property");
Copy link
Contributor

Choose a reason for hiding this comment

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

ok to skip 👍

@@ -643,6 +643,12 @@ bool swift::checkDistributedActorProperty(VarDecl *var, bool diagnose) {
void swift::checkDistributedActorProperties(const NominalTypeDecl *decl) {
auto &C = decl->getASTContext();

auto sourceFile = decl->getDeclContext()->getParentSourceFile();
if (sourceFile && sourceFile->Kind == SourceFileKind::Interface) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh I see, this looks good 👍

Some decls that are expected to be synthesized for distributed actors are
printed explicitly in swiftinterfaces so diagnostics and assertions need to
take that possibility into account.

Resolves rdar://108533918
@tshortli tshortli force-pushed the distributed-actor-swiftinterface branch from 9577c3c to 0e9b8a1 Compare April 26, 2023 15:45
@tshortli
Copy link
Contributor Author

@swift-ci please smoke test

Copy link
Contributor

@xedin xedin left a comment

Choose a reason for hiding this comment

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

I'm not sure whether it matters or not but there are similar implicitness checks in SILGenDistributed.cpp as well, should that be reworked too?

@tshortli
Copy link
Contributor Author

I'm not sure whether it matters or not but there are similar implicitness checks in SILGenDistributed.cpp as well, should that be reworked too?

Thanks for thinking of that Pavel! I experimented with a few different approaches to seeing if that might be an issue but I wasn't able to reproduce any failures. I tried -compile-module-from-interface to verify that the module can be serialized successfully and also ran -emit-sil on the swiftinterface produced by the test case and those both seemed to be happy with the input. Do you think there's anything else I should try?

@xedin
Copy link
Contributor

xedin commented Apr 26, 2023

That sounds reasonable but @ktoso knows more about the system/id synthesis inside of initializers than I do.

@tshortli
Copy link
Contributor Author

Since this change appears to succeed at unblocking module interface verification I'm going to land this. If we discover ways in which SILGen also needs to be tweaked let's do that in a separate PR.

@tshortli tshortli merged commit d18b2ca into swiftlang:main Apr 26, 2023
@tshortli tshortli deleted the distributed-actor-swiftinterface branch April 26, 2023 20:38
@ktoso
Copy link
Contributor

ktoso commented Apr 26, 2023

Hmmm, as far as I can tell these would be the only place where we're diagnosing errors on the synthesized things so this should be enough.

Thank you very much for the investigation and fix @tshortli!

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