-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Distributed] improve ad-hoc requirement typechecking #41179
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
Conversation
506092e
to
2355c17
Compare
@swift-ci please smoke test and merge |
lib/AST/Decl.cpp
Outdated
|
||
size_t expectedRequirementsNum = 3; | ||
if (!isVoidReturn) { | ||
// TODO(distributed): support alternative SerializationRequirements here |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is an alternative way to check this:
- Lookup declaring type - should be an implementation of
DistributedActorSystem
- Find a concrete serialization requirement associated with it e.g.
Codable
- Find a concrete
InvocationDecoder
type - Extract either a single protocol type or a set of protocols (if requirement is a ProtocolCompositionType)
- Structural checks:
- async + throws
- Has 3 generic parameters
- Has required number of parameters,
- labels match (!)
- result type is represented by a generic parameter or
Void
- Check that parameter at index
0
is a generic parameter and it conforms toDistributedActor
- Check that parameter at index
1
is a known type -RemoteCallTarget
(you'd have to make that type known to the compiler) - Check that parameter at index
2
is equal to concrete type ofInvocationDecoder
and parameter isinout
- Check that parameter at index
3
is a metatype of a generic parameter orVoid
and if it's former that it "covers" all of the protocols from step 3 (you can get a set of requirements associated with a given generic parameter viaGenericSignature::RequiredProtocols getRequiredProtocols(Type type) const;
). - Check that parameter at index
4
is a metatype of generic parameter and generic parameter has a requirement forError
(samegetRequiredProtocols
call).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could either check the label list of equivalence or do per-parameter label checks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks -- getting back to this now :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the hints this makes it much cleaner; Only halfway through so far since i implemented dealing with the serialization req a bit more. Shaping up well tho
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done and more cleanups along the way.
Made good progress here -- lots of cleanup and moving around utilities to work with the associated types (serialization req) and desugaring it etc... I think I should have this complete tomorrow. |
2355c17
to
8549764
Compare
8549764
to
0fec1b3
Compare
@swift-ci please smoke test |
Did a good next pass here, all checks on remote calls are done I think. Will continue with the other ones which will be pretty simple. There is still a bit code duplication around dealing with types... I'll be cleaning up more and more as follow up as I implement the rest -- maybe tomorrow |
There was a problem hiding this 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 so far! Please don't forgot to remove all of the fprintf debug logging. Also FYI you can use llvm::errs()
to make it simpler for yourself since it works the same way as std::cout
and doesn't require format strings :)
Thanks -- done a lot here and going to try to get this step in; there's one more protocol to handle the result handler with its onReturn but I'll do this in a small PR |
@swift-ci please smoke test |
4e199b7
to
29357be
Compare
29357be
to
1caa0b1
Compare
return fd; | ||
} | ||
|
||
return nullptr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved all these to requests and implemented properly
@@ -43,6 +43,7 @@ add_swift_host_library(swiftAST STATIC | |||
DiagnosticConsumer.cpp | |||
DiagnosticEngine.cpp | |||
DiagnosticList.cpp | |||
DistributedDecl.cpp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new common place for all our "get this, get that"
@swift-ci please smoke test |
// Act.ID == ActorID | ||
{ | ||
Act.ID == ActorID, | ||
Err: Error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uncommented and requiring those properly now
Had some issues with the mutable checking but will revisit this later |
@swift-ci please smoke test and merge |
2262286
to
30c18a9
Compare
30c18a9
to
b02f9c7
Compare
@swift-ci please smoke test and merge |
@swift-ci please smoke test and merge |
Flaky lldb tests:
|
@swift-ci please smoke test macOS |
|
@swift-ci please smoke test macOS |
3 similar comments
@swift-ci please smoke test macOS |
@swift-ci please smoke test macOS |
@swift-ci please smoke test macOS |
@swift-ci please build toolchain |
resolves rdar://88111680 |
Improves the matching of ad-hoc protocol requirements remoteCall / remoteCallVoid.
Dealing with the generics there is a pain in the neck but we're almost there...
This isn't a complete impl still, it has to check the param of the
Act
and the SerializationRequirements still