[Distributed] SILGen must consistently use prop get requests

This commit is contained in:
Konrad `ktoso` Malawski
2022-04-23 07:49:54 +09:00
parent 1b5c3d79dd
commit e01bcc470f
4 changed files with 43 additions and 49 deletions

View File

@@ -38,6 +38,42 @@ using namespace swift;
/************************ PROPERTY SYNTHESIS **********************************/
/******************************************************************************/
static VarDecl*
lookupDistributedActorProperty(NominalTypeDecl *decl, DeclName name) {
assert(decl && "decl was null");
auto &C = decl->getASTContext();
auto clazz = dyn_cast<ClassDecl>(decl);
if (!clazz)
return nullptr;
auto refs = decl->lookupDirect(name);
if (refs.size() != 1)
return nullptr;
auto var = dyn_cast<VarDecl>(refs.front());
if (!var)
return nullptr;
Type expectedType = Type();
if (name == C.Id_id) {
expectedType = getDistributedActorIDType(decl);
} else if (name == C.Id_actorSystem) {
expectedType = getDistributedActorSystemType(decl);
} else {
llvm_unreachable("Unexpected distributed actor property lookup!");
}
if (!expectedType)
return nullptr;
if (!var->getInterfaceType()->isEqual(expectedType))
return nullptr;
assert(var->isSynthesized() && "Expected compiler synthesized property");
return var;
}
// Note: This would be nice to implement in DerivedConformanceDistributedActor,
// but we can't since those are lazily triggered and an implementation exists
// for the 'id' property because 'Identifiable.id' has an extension that impls