Skip to content

Commit c97ebb0

Browse files
committed
[Sema] Fix SR-1681: spurious "unused result" warning in Swift 3
An OptionalEvaluationExpr can have a CallExpr directly as its SubExpr, if the CallExpr already has optional type. extends ea52d4f
1 parent 80f0044 commit c97ebb0

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/Sema/TypeCheckStmt.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1080,9 +1080,12 @@ void TypeChecker::checkIgnoredExpr(Expr *E) {
10801080
// If we have an OptionalEvaluationExpr at the top level, then someone is
10811081
// "optional chaining" and ignoring the result. Produce a diagnostic if it
10821082
// doesn't make sense to ignore it.
1083-
if (auto *OEE = dyn_cast<OptionalEvaluationExpr>(valueE))
1083+
if (auto *OEE = dyn_cast<OptionalEvaluationExpr>(valueE)) {
10841084
if (auto *IIO = dyn_cast<InjectIntoOptionalExpr>(OEE->getSubExpr()))
10851085
return checkIgnoredExpr(IIO->getSubExpr());
1086+
if (auto *C = dyn_cast<CallExpr>(OEE->getSubExpr()))
1087+
return checkIgnoredExpr(C);
1088+
}
10861089

10871090
// Check if we have a call to a function not marked with
10881091
// '@discardableResult'.

0 commit comments

Comments
 (0)