-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[DNM][Distributed] Handle generic actors and Codable better #71467
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
Closed
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
02e46c1
[ConstraintSystem] NFC: Pass an underlying declaration to `Solution::…
xedin e40c66f
[AST] Add a way to determine whether declaration is `remoteCall` requ…
xedin 40704ac
[stdlib] Distributed: Promote `remoteCall{Void}` into protocol requir…
xedin 089596a
[TypeChecker] Allow missing requirements on `Res` generic parameter o…
xedin 8223abe
[CSApply] Produce an abstract conformance for `Res` parameter of `Dis…
xedin 675441d
[IRGen] Implement dynamic witness table lookup for `Res` of `Distribu…
xedin 5f669bb
[Distributed] handle generic actors and Codable better
ktoso f4d384d
cleanup tests
ktoso e23feda
[Distributed] if a generic provides ActorSystem, don't synthesize typ…
ktoso File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,24 +12,25 @@ | |
|
||
#include "TypeCheckDistributed.h" | ||
|
||
#include "TypeChecker.h" | ||
#include "DerivedConformances.h" | ||
#include "TypeCheckType.h" | ||
#include "TypeChecker.h" | ||
#include "swift/AST/ASTMangler.h" | ||
#include "swift/AST/ASTPrinter.h" | ||
#include "swift/AST/Availability.h" | ||
#include "swift/AST/DistributedDecl.h" | ||
#include "swift/AST/ExistentialLayout.h" | ||
#include "swift/AST/Expr.h" | ||
#include "swift/AST/GenericEnvironment.h" | ||
#include "swift/AST/Initializer.h" | ||
#include "swift/AST/NameLookupRequests.h" | ||
#include "swift/AST/ParameterList.h" | ||
#include "swift/AST/TypeCheckRequests.h" | ||
#include "swift/AST/NameLookupRequests.h" | ||
#include "swift/AST/ASTMangler.h" | ||
#include "swift/AST/DistributedDecl.h" | ||
#include "swift/Basic/Defer.h" | ||
#include "swift/ClangImporter/ClangModule.h" | ||
#include "swift/Sema/ConstraintSystem.h" | ||
#include "llvm/ADT/SmallString.h" | ||
#include "llvm/ADT/StringExtras.h" | ||
#include "DerivedConformances.h" | ||
|
||
using namespace swift; | ||
|
||
|
@@ -750,11 +751,8 @@ static FuncDecl *createDistributedThunkFunction(FuncDecl *func) { | |
/*********************** CODABLE CONFORMANCE **********************************/ | ||
/******************************************************************************/ | ||
|
||
static NormalProtocolConformance* | ||
addDistributedActorCodableConformance( | ||
ClassDecl *actor, ProtocolDecl *proto) { | ||
assert(proto->isSpecificProtocol(swift::KnownProtocolKind::Decodable) || | ||
proto->isSpecificProtocol(swift::KnownProtocolKind::Encodable)); | ||
static NormalProtocolConformance * | ||
addDistributedActorCodableConformance(ClassDecl *actor, ProtocolDecl *proto) { | ||
auto &C = actor->getASTContext(); | ||
auto module = actor->getParentModule(); | ||
|
||
|
@@ -763,6 +761,32 @@ addDistributedActorCodableConformance( | |
return nullptr; | ||
} | ||
|
||
if (actor->isGeneric()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you want isGeneric() or isGenericContext()? |
||
auto idTy = | ||
C.getAssociatedTypeOfDistributedSystemOfActor(actor, C.Id_ActorID); | ||
if (idTy->hasError()) { | ||
return nullptr; | ||
} | ||
auto encodableConf = module->lookupConformance( | ||
idTy, C.getProtocol(swift::KnownProtocolKind::Encodable), | ||
/*allowMissing=*/true); | ||
auto decodableConf = module->lookupConformance( | ||
idTy, C.getProtocol(swift::KnownProtocolKind::Decodable), | ||
/*allowMissing=*/true); | ||
|
||
// the system's ID is not codable, thus the actor isn't as well -- don't add | ||
// the conformance. | ||
if (encodableConf.isInvalid()) { | ||
return nullptr; | ||
} | ||
if (decodableConf.isInvalid()) { | ||
return nullptr; | ||
} | ||
} | ||
|
||
assert(proto->isSpecificProtocol(swift::KnownProtocolKind::Decodable) || | ||
proto->isSpecificProtocol(swift::KnownProtocolKind::Encodable)); | ||
|
||
// === Does the actor explicitly conform to the protocol already? | ||
auto explicitConformance = | ||
module->lookupConformance(actor->getInterfaceType(), proto); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will always return false because getInterfaceType() returns a metatype given a TypeDecl |
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.