Skip to content

Commit c225db4

Browse files
committed
[CSApply] NFC: Simplify coerceSelfArgumentToType
`coerceToType` can to handle l-value -> inout correctly and report better information if coercion fails.
1 parent 55189ba commit c225db4

File tree

1 file changed

+1
-18
lines changed

1 file changed

+1
-18
lines changed

lib/Sema/CSApply.cpp

+1-18
Original file line numberDiff line numberDiff line change
@@ -7953,24 +7953,7 @@ ExprRewriter::coerceSelfArgumentToType(Expr *expr,
79537953
Type baseTy, ValueDecl *member,
79547954
ConstraintLocatorBuilder locator) {
79557955
Type toType = adjustSelfTypeForMember(expr, baseTy, member, dc);
7956-
7957-
// If our expression already has the right type, we're done.
7958-
Type fromType = cs.getType(expr);
7959-
if (fromType->isEqual(toType))
7960-
return expr;
7961-
7962-
// If we're coercing to an rvalue type, just do it.
7963-
auto toInOutTy = toType->getAs<InOutType>();
7964-
if (!toInOutTy)
7965-
return coerceToType(expr, toType, locator);
7966-
7967-
assert(fromType->is<LValueType>() && "Can only convert lvalues to inout");
7968-
7969-
// Use InOutExpr to convert it to an explicit inout argument for the
7970-
// receiver.
7971-
return cs.cacheType(new (ctx) InOutExpr(expr->getStartLoc(), expr,
7972-
toInOutTy->getInOutObjectType(),
7973-
/*isImplicit*/ true));
7956+
return coerceToType(expr, toType, locator);
79747957
}
79757958

79767959
Expr *ExprRewriter::convertLiteralInPlace(

0 commit comments

Comments
 (0)