Skip to content

Commit d8b06ae

Browse files
authored
[AST] Return null type in AbstractClosureExpr::getResultType if getType is null (#37362)
If `getType` returns a `null` type, also return a `null` type in `AbstractClosureExpr::getResultType` instead of crashing. Fixes rdar://77565983
1 parent ccb7d76 commit d8b06ae

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/AST/Expr.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1931,10 +1931,11 @@ void AbstractClosureExpr::setParameterList(ParameterList *P) {
19311931
Type AbstractClosureExpr::getResultType(
19321932
llvm::function_ref<Type(Expr *)> getType) const {
19331933
auto *E = const_cast<AbstractClosureExpr *>(this);
1934-
if (getType(E)->hasError())
1935-
return getType(E);
1934+
Type T = getType(E);
1935+
if (!T || T->hasError())
1936+
return T;
19361937

1937-
return getType(E)->castTo<FunctionType>()->getResult();
1938+
return T->castTo<FunctionType>()->getResult();
19381939
}
19391940

19401941
bool AbstractClosureExpr::isBodyThrowing() const {

0 commit comments

Comments
 (0)