@@ -3592,12 +3592,8 @@ namespace {
3592
3592
Expr *argExpr = new (ctx) StringLiteralExpr (msg, E->getLoc (),
3593
3593
/* implicit*/ true );
3594
3594
3595
- auto getType = [&](const Expr *E) -> Type {
3596
- return cs.getType (E);
3597
- };
3598
-
3599
3595
Expr *callExpr = CallExpr::createImplicit (ctx, fnRef, { argExpr },
3600
- { Identifier () }, getType );
3596
+ { Identifier () });
3601
3597
3602
3598
bool invalid = tc.typeCheckExpression (callExpr, cs.DC ,
3603
3599
TypeLoc::withoutLoc (valueType),
@@ -6037,11 +6033,12 @@ Expr *ExprRewriter::convertLiteral(Expr *literal,
6037
6033
cs.cacheExprTypes (base);
6038
6034
cs.setExprTypes (base);
6039
6035
cs.setExprTypes (literal);
6036
+ SmallVector<Expr *, 1 > arguments = { literal };
6040
6037
6041
6038
Expr *result = tc.callWitness (base, dc,
6042
6039
builtinProtocol, *builtinConformance,
6043
6040
builtinLiteralFuncName,
6044
- literal ,
6041
+ arguments ,
6045
6042
brokenBuiltinProtocolDiag);
6046
6043
if (result)
6047
6044
cs.cacheExprTypes (result);
@@ -7230,6 +7227,9 @@ Expr *TypeChecker::callWitness(Expr *base, DeclContext *dc,
7230
7227
// Construct an empty constraint system and solution.
7231
7228
ConstraintSystem cs (*this , dc, ConstraintSystemOptions ());
7232
7229
7230
+ for (auto *arg : arguments)
7231
+ cs.cacheType (arg);
7232
+
7233
7233
// Find the witness we need to use.
7234
7234
auto type = base->getType ();
7235
7235
assert (!type->hasTypeVariable () &&
@@ -7275,7 +7275,7 @@ Expr *TypeChecker::callWitness(Expr *base, DeclContext *dc,
7275
7275
auto argLabels = witness->getFullName ().getArgumentNames ();
7276
7276
if (arguments.size () == 1 &&
7277
7277
(isVariadicWitness (witness) ||
7278
- argumentNamesMatch (arguments[0 ]-> getType ( ), argLabels))) {
7278
+ argumentNamesMatch (cs. getType ( arguments[0 ]), argLabels))) {
7279
7279
call = CallExpr::create (Context, unresolvedDot, arguments[0 ], {}, {},
7280
7280
/* hasTrailingClosure=*/ false ,
7281
7281
/* implicit=*/ true , Type (), getType);
0 commit comments