@@ -4045,20 +4045,19 @@ namespace {
4045
4045
}
4046
4046
4047
4047
Expr *visitCoerceExpr (CoerceExpr *expr) {
4048
+ auto *coerced = visitCoerceExprImpl (expr);
4049
+ if (!coerced)
4050
+ return nullptr ;
4051
+
4048
4052
// If we need to insert a force-unwrap for coercions of the form
4049
4053
// '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);
4057
4056
4058
- return visitCoerceExpr (expr, None) ;
4057
+ return coerced ;
4059
4058
}
4060
4059
4061
- Expr *visitCoerceExpr (CoerceExpr *expr, Optional< unsigned > choice ) {
4060
+ Expr *visitCoerceExprImpl (CoerceExpr *expr) {
4062
4061
// Simplify and update the type we're coercing to.
4063
4062
assert (expr->getCastTypeRepr ());
4064
4063
const auto toType = simplifyType (cs.getType (expr->getCastTypeRepr ()));
@@ -4107,14 +4106,11 @@ namespace {
4107
4106
// get it from the solution to determine whether we've picked a coercion
4108
4107
// or a bridging conversion.
4109
4108
auto *locator = cs.getConstraintLocator (expr);
4110
-
4111
- if (!choice) {
4112
- choice = solution.getDisjunctionChoice (locator);
4113
- }
4109
+ auto choice = solution.getDisjunctionChoice (locator);
4114
4110
4115
4111
// Handle the coercion/bridging of the underlying subexpression, where
4116
4112
// optionality has been removed.
4117
- if (* choice == 0 ) {
4113
+ if (choice == 0 ) {
4118
4114
// Convert the subexpression.
4119
4115
Expr *sub = expr->getSubExpr ();
4120
4116
@@ -4128,7 +4124,7 @@ namespace {
4128
4124
}
4129
4125
4130
4126
// Bridging conversion.
4131
- assert (* choice == 1 && " should be bridging" );
4127
+ assert (choice == 1 && " should be bridging" );
4132
4128
4133
4129
// Handle optional bindings.
4134
4130
Expr *sub = handleOptionalBindings (expr->getSubExpr (), toType,
0 commit comments