SIL: Type lowering support for indirect error results

This commit is contained in:
Slava Pestov
2023-10-26 22:46:39 -04:00
parent 1d05c356c4
commit b84df92b70
2 changed files with 46 additions and 28 deletions

View File

@@ -2627,14 +2627,28 @@ public:
if (yieldType) {
substYieldType = visit(yieldType, yieldPattern);
}
CanType newErrorType;
if (auto optPair = pattern.getFunctionThrownErrorType(func)) {
auto errorPattern = optPair->first;
auto errorType = optPair->second;
newErrorType = visit(errorType, errorPattern);
}
auto newResultTy = visit(func.getResult(),
pattern.getFunctionResultType());
llvm::Optional<FunctionType::ExtInfo> extInfo;
if (func->hasExtInfo())
extInfo = func->getExtInfo();
if (newErrorType) {
if (!extInfo)
extInfo = FunctionType::ExtInfo();
extInfo = extInfo->withThrows(true, newErrorType);
}
return CanFunctionType::get(FunctionType::CanParamArrayRef(newParams),
newResultTy, extInfo);
}