mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Introduce then statements
These allow multi-statement `if`/`switch` expression branches that can produce a value at the end by saying `then <expr>`. This is gated behind `-enable-experimental-feature ThenStatements` pending evolution discussion.
This commit is contained in:
@@ -3872,10 +3872,10 @@ namespace {
|
||||
if (auto *SVE = expr->getSingleValueStmtExpr()) {
|
||||
// If we have a SingleValueStmtExpr, form a join of the branch types.
|
||||
SmallVector<Expr *, 4> scratch;
|
||||
auto branches = SVE->getSingleExprBranches(scratch);
|
||||
auto branches = SVE->getResultExprs(scratch);
|
||||
for (auto idx : indices(branches)) {
|
||||
auto *eltLoc = CS.getConstraintLocator(
|
||||
SVE, {LocatorPathElt::SingleValueStmtBranch(idx)});
|
||||
SVE, {LocatorPathElt::SingleValueStmtResult(idx)});
|
||||
elements.emplace_back(CS.getType(branches[idx]), eltLoc);
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user