Skip to content

Commit

Permalink
Merge pull request #24546 from nate-chandler/nate/omit-return-pr-fixes
Browse files Browse the repository at this point in the history
Address PR comments on return omission.
  • Loading branch information
nate-chandler authored May 7, 2019
2 parents 49710ab + 1267f65 commit 5e7f06d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
4 changes: 1 addition & 3 deletions lib/Parse/ParseDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5694,9 +5694,7 @@ void Parser::parseAbstractFunctionBody(AbstractFunctionDecl *AFD) {
if (!Body.hasCodeCompletion() && BS->getNumElements() == 1) {
auto Element = BS->getElement(0);
if (auto *stmt = Element.dyn_cast<Stmt *>()) {
auto kind = AFD->getKind();
if (kind == DeclKind::Var || kind == DeclKind::Subscript ||
kind == DeclKind::Func ) {
if (isa<FuncDecl>(AFD)) {
if (auto *returnStmt = dyn_cast<ReturnStmt>(stmt)) {
if (!returnStmt->hasResult()) {
auto returnExpr = TupleExpr::createEmpty(Context,
Expand Down
2 changes: 1 addition & 1 deletion lib/SILOptimizer/Mandatory/DataflowDiagnostics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ static void diagnoseMissingReturn(const UnreachableInst *UI,
if (numElements > 0) {
auto element = BS->getElement(numElements - 1);
if (auto expr = element.dyn_cast<Expr *>()) {
if (expr->getType()->getCanonicalType() == ResTy->getCanonicalType()) {
if (expr->getType()->isEqual(ResTy)) {
Context.Diags.diagnose(
expr->getStartLoc(),
diag::missing_return_last_expr, ResTy,
Expand Down

0 comments on commit 5e7f06d

Please sign in to comment.