SILGen: Implement native-to-foreign thunks for async methods.

Bridging an async Swift method back to an ObjC completion-handler-based API requires
that the ObjC thunk spawn a task on which to execute the Swift async API and pass
its results back on to the completion handler.
This commit is contained in:
Joe Groff
2020-12-03 17:57:01 -08:00
parent 8914ba60fd
commit 5087e411c2
9 changed files with 340 additions and 48 deletions

View File

@@ -1230,3 +1230,13 @@ bool SILDeclRef::isDynamicallyReplaceable() const {
// enabled.
return decl->shouldUseNativeMethodReplacement();
}
bool SILDeclRef::hasAsync() const {
if (hasDecl()) {
if (auto afd = dyn_cast<AbstractFunctionDecl>(getDecl())) {
return afd->hasAsync();
}
return false;
}
return getAbstractClosureExpr()->isBodyAsync();
}