Skip to content

Commit 5482bbf

Browse files
committed
SIL: Walk into the thrown error type when computing substituted generic signature
1 parent 7a54e78 commit 5482bbf

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

lib/SIL/IR/AbstractionPattern.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2597,14 +2597,26 @@ class SubstFunctionTypePatternVisitor
25972597
if (yieldType) {
25982598
substYieldType = visit(yieldType, yieldPattern);
25992599
}
2600-
2600+
2601+
CanType newErrorType;
2602+
if (auto optErrorType = func->getEffectiveThrownErrorType()) {
2603+
newErrorType = visit((*optErrorType)->getCanonicalType(),
2604+
pattern.getFunctionThrownErrorType());
2605+
}
2606+
26012607
auto newResultTy = visit(func.getResult(),
26022608
pattern.getFunctionResultType());
26032609

26042610
llvm::Optional<FunctionType::ExtInfo> extInfo;
26052611
if (func->hasExtInfo())
26062612
extInfo = func->getExtInfo();
2607-
2613+
2614+
if (newErrorType) {
2615+
if (!extInfo)
2616+
extInfo = FunctionType::ExtInfo();
2617+
extInfo = extInfo->withThrows(true, newErrorType);
2618+
}
2619+
26082620
return CanFunctionType::get(FunctionType::CanParamArrayRef(newParams),
26092621
newResultTy, extInfo);
26102622
}

0 commit comments

Comments
 (0)