Skip to content

Commit 7b9c079

Browse files
committed
Be more careful when getting the effective thrown error type
1 parent b51ad81 commit 7b9c079

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/AST/Decl.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -963,8 +963,10 @@ AbstractFunctionDecl::getEffectiveThrownErrorType() const {
963963
interfaceType = fnType->getResult();
964964
}
965965

966-
return interfaceType->castTo<AnyFunctionType>()
967-
->getEffectiveThrownErrorType();
966+
if (auto fnType = interfaceType->getAs<AnyFunctionType>())
967+
return fnType->getEffectiveThrownErrorType();
968+
969+
return llvm::None;
968970
}
969971

970972
Expr *AbstractFunctionDecl::getSingleExpressionBody() const {

0 commit comments

Comments
 (0)