Skip to content

Commit 4e28c30

Browse files
committed
Address PR comments on return omission.
1 parent fd9048c commit 4e28c30

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

lib/Parse/ParseDecl.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5649,9 +5649,7 @@ void Parser::parseAbstractFunctionBody(AbstractFunctionDecl *AFD) {
56495649
if (!Body.hasCodeCompletion() && BS->getNumElements() == 1) {
56505650
auto Element = BS->getElement(0);
56515651
if (auto *stmt = Element.dyn_cast<Stmt *>()) {
5652-
auto kind = AFD->getKind();
5653-
if (kind == DeclKind::Var || kind == DeclKind::Subscript ||
5654-
kind == DeclKind::Func ) {
5652+
if (isa<FuncDecl>(AFD)) {
56555653
if (auto *returnStmt = dyn_cast<ReturnStmt>(stmt)) {
56565654
if (!returnStmt->hasResult()) {
56575655
auto returnExpr = TupleExpr::createEmpty(Context,

lib/SILOptimizer/Mandatory/DataflowDiagnostics.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ static void diagnoseMissingReturn(const UnreachableInst *UI,
6363
if (numElements > 0) {
6464
auto element = BS->getElement(numElements - 1);
6565
if (auto expr = element.dyn_cast<Expr *>()) {
66-
if (expr->getType()->getCanonicalType() == ResTy->getCanonicalType()) {
66+
if (expr->getType()->isEqual(ResTy)) {
6767
Context.Diags.diagnose(
6868
expr->getStartLoc(),
6969
diag::missing_return_last_expr, ResTy,

0 commit comments

Comments
 (0)