mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Further hardening: new compiler + old SDK still diagnose correctly
This commit is contained in:
@@ -5343,7 +5343,8 @@ NominalTypeDecl::getExecutorOwnedEnqueueFunction() const {
|
||||
if (params->size() != 1)
|
||||
continue;
|
||||
|
||||
if (params->get(0)->getSpecifier() == ParamSpecifier::LegacyOwned && // TODO: make this Consuming
|
||||
if ((params->get(0)->getSpecifier() == ParamSpecifier::LegacyOwned ||
|
||||
params->get(0)->getSpecifier() == ParamSpecifier::Consuming) &&
|
||||
params->get(0)->getInterfaceType()->isEqual(executorJobDecl->getDeclaredInterfaceType())) {
|
||||
return funcDecl;
|
||||
}
|
||||
@@ -5381,7 +5382,8 @@ NominalTypeDecl::getExecutorLegacyOwnedEnqueueFunction() const {
|
||||
if (params->size() != 1)
|
||||
continue;
|
||||
|
||||
if (params->get(0)->getSpecifier() == ParamSpecifier::LegacyOwned && // TODO: make this Consuming
|
||||
if ((params->get(0)->getSpecifier() == ParamSpecifier::LegacyOwned ||
|
||||
params->get(0)->getSpecifier() == ParamSpecifier::Consuming) &&
|
||||
params->get(0)->getType()->isEqual(legacyJobDecl->getDeclaredInterfaceType())) {
|
||||
return funcDecl;
|
||||
}
|
||||
@@ -5391,6 +5393,43 @@ NominalTypeDecl::getExecutorLegacyOwnedEnqueueFunction() const {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
AbstractFunctionDecl *
|
||||
NominalTypeDecl::getExecutorLegacyUnownedEnqueueFunction() const {
|
||||
auto &C = getASTContext();
|
||||
StructDecl *unownedJobDecl = C.getUnownedJobDecl();
|
||||
if (!unownedJobDecl)
|
||||
return nullptr;
|
||||
|
||||
auto proto = dyn_cast<ProtocolDecl>(this);
|
||||
if (!proto)
|
||||
return nullptr;
|
||||
|
||||
llvm::SmallVector<ValueDecl *, 2> results;
|
||||
lookupQualified(getSelfNominalTypeDecl(),
|
||||
DeclNameRef(C.Id_enqueue),
|
||||
NL_ProtocolMembers,
|
||||
results);
|
||||
|
||||
for (auto candidate: results) {
|
||||
// we're specifically looking for the Executor protocol requirement
|
||||
if (!isa<ProtocolDecl>(candidate->getDeclContext()))
|
||||
continue;
|
||||
|
||||
if (auto *funcDecl = dyn_cast<AbstractFunctionDecl>(candidate)) {
|
||||
auto params = funcDecl->getParameters();
|
||||
|
||||
if (params->size() != 1)
|
||||
continue;
|
||||
|
||||
if (params->get(0)->getType()->isEqual(unownedJobDecl->getDeclaredInterfaceType())) {
|
||||
return funcDecl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ClassDecl::ClassDecl(SourceLoc ClassLoc, Identifier Name, SourceLoc NameLoc,
|
||||
ArrayRef<InheritedEntry> Inherited,
|
||||
GenericParamList *GenericParams, DeclContext *Parent,
|
||||
|
||||
Reference in New Issue
Block a user