Skip to content

Commit aa6942e

Browse files
committed
[CS] Simplify visitCoerceExpr slightly
Remove the unused `choice` parameter.
1 parent cddb08a commit aa6942e

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

lib/Sema/CSApply.cpp

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4045,20 +4045,19 @@ namespace {
40454045
}
40464046

40474047
Expr *visitCoerceExpr(CoerceExpr *expr) {
4048+
auto *coerced = visitCoerceExprImpl(expr);
4049+
if (!coerced)
4050+
return nullptr;
4051+
40484052
// If we need to insert a force-unwrap for coercions of the form
40494053
// 'as T!', do so now.
4050-
if (hasForcedOptionalResult(expr)) {
4051-
auto *coerced = visitCoerceExpr(expr, None);
4052-
if (!coerced)
4053-
return nullptr;
4054-
4055-
return forceUnwrapIUO(coerced);
4056-
}
4054+
if (hasForcedOptionalResult(expr))
4055+
coerced = forceUnwrapIUO(coerced);
40574056

4058-
return visitCoerceExpr(expr, None);
4057+
return coerced;
40594058
}
40604059

4061-
Expr *visitCoerceExpr(CoerceExpr *expr, Optional<unsigned> choice) {
4060+
Expr *visitCoerceExprImpl(CoerceExpr *expr) {
40624061
// Simplify and update the type we're coercing to.
40634062
assert(expr->getCastTypeRepr());
40644063
const auto toType = simplifyType(cs.getType(expr->getCastTypeRepr()));
@@ -4107,14 +4106,11 @@ namespace {
41074106
// get it from the solution to determine whether we've picked a coercion
41084107
// or a bridging conversion.
41094108
auto *locator = cs.getConstraintLocator(expr);
4110-
4111-
if (!choice) {
4112-
choice = solution.getDisjunctionChoice(locator);
4113-
}
4109+
auto choice = solution.getDisjunctionChoice(locator);
41144110

41154111
// Handle the coercion/bridging of the underlying subexpression, where
41164112
// optionality has been removed.
4117-
if (*choice == 0) {
4113+
if (choice == 0) {
41184114
// Convert the subexpression.
41194115
Expr *sub = expr->getSubExpr();
41204116

@@ -4128,7 +4124,7 @@ namespace {
41284124
}
41294125

41304126
// Bridging conversion.
4131-
assert(*choice == 1 && "should be bridging");
4127+
assert(choice == 1 && "should be bridging");
41324128

41334129
// Handle optional bindings.
41344130
Expr *sub = handleOptionalBindings(expr->getSubExpr(), toType,

0 commit comments

Comments
 (0)