[Concurrency] Fix how we obtain DA-as-A conformance for cross module

Resolves rdar://127206143
This commit is contained in:
Konrad `ktoso` Malawski
2024-05-28 13:37:16 +09:00
parent 545c2434c0
commit 168bc7b454
14 changed files with 399 additions and 135 deletions

View File

@@ -14,7 +14,6 @@
#include "CodeSynthesis.h"
#include "DerivedConformances.h"
#include "TypeCheckType.h"
#include "TypeChecker.h"
#include "swift/AST/ASTMangler.h"
#include "swift/AST/ASTPrinter.h"
@@ -1066,3 +1065,30 @@ bool CanSynthesizeDistributedActorCodableConformanceRequest::evaluate(
TypeChecker::conformsToKnownProtocol(
idTy, KnownProtocolKind::Encodable, actor->getParentModule());
}
NormalProtocolConformance *
GetDistributedActorAsActorConformanceRequest::evaluate(
Evaluator &evaluator, ProtocolDecl *distributedActorProto) const {
auto &ctx = distributedActorProto->getASTContext();
auto swiftModule = ctx.getStdlibModule();
auto actorProto = ctx.getProtocol(KnownProtocolKind::Actor);
auto ext = findDistributedActorAsActorExtension(
distributedActorProto, swiftModule);
if (!ext)
return nullptr;
auto genericParam = GenericTypeParamType::get(/*isParameterPack=*/false,
/*depth=*/0, /*index=*/0, ctx);
auto distributedActorAsActorConformance = ctx.getNormalConformance(
Type(genericParam), actorProto, SourceLoc(), ext,
ProtocolConformanceState::Incomplete, /*isUnchecked=*/false,
/*isPreconcurrency=*/false);
// NOTE: Normally we "register" a conformance, but here we don't
// because we cannot (currently) register them in a protocol,
// since they do not have conformance tables.
return distributedActorAsActorConformance;
}