Skip to content

Commit ff34795

Browse files
committed
[Sema] Use getResultInterfaceType() to get the result type
In `TypeCheckFunctionBodyUntilRequest`. So we can type check the body without typechecking the signature.
1 parent fdec50a commit ff34795

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

lib/Sema/TypeCheckStmt.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2121,15 +2121,11 @@ TypeCheckFunctionBodyUntilRequest::evaluate(Evaluator &evaluator,
21212121
builderType);
21222122
if (!body)
21232123
return true;
2124-
} else if (func->hasSingleExpressionBody()) {
2125-
auto resultTypeLoc = func->getBodyResultTypeLoc();
2126-
auto expr = func->getSingleExpressionBody();
2127-
2128-
if (resultTypeLoc.isNull() || resultTypeLoc.getType()->isVoid()) {
2129-
// The function returns void. We don't need an explicit return, no matter
2130-
// what the type of the expression is. Take the inserted return back out.
2131-
body->setFirstElement(expr);
2132-
}
2124+
} else if (func->hasSingleExpressionBody() &&
2125+
func->getResultInterfaceType()->isVoid()) {
2126+
// The function returns void. We don't need an explicit return, no matter
2127+
// what the type of the expression is. Take the inserted return back out.
2128+
body->setFirstElement(func->getSingleExpressionBody());
21332129
}
21342130
} else if (isa<ConstructorDecl>(AFD) &&
21352131
(body->empty() ||

0 commit comments

Comments
 (0)