Skip to content

Commit 6ee6378

Browse files
authored
Merge pull request #8029 from rudkx/more-cs-typemap
2 parents c4599d9 + b592260 commit 6ee6378

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

lib/AST/Expr.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1749,7 +1749,8 @@ CallExpr *CallExpr::create(ASTContext &ctx, Expr *fn, SourceLoc lParenLoc,
17491749
SmallVector<SourceLoc, 4> argLabelLocsScratch;
17501750
Expr *arg = packSingleArgument(ctx, lParenLoc, args, argLabels, argLabelLocs,
17511751
rParenLoc, trailingClosure, implicit,
1752-
argLabelsScratch, argLabelLocsScratch);
1752+
argLabelsScratch, argLabelLocsScratch,
1753+
getType);
17531754

17541755
size_t size = totalSizeToAlloc(argLabels, argLabelLocs,
17551756
trailingClosure != nullptr);

lib/Sema/CSApply.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3592,12 +3592,8 @@ namespace {
35923592
Expr *argExpr = new (ctx) StringLiteralExpr(msg, E->getLoc(),
35933593
/*implicit*/true);
35943594

3595-
auto getType = [&](const Expr *E) -> Type {
3596-
return cs.getType(E);
3597-
};
3598-
35993595
Expr *callExpr = CallExpr::createImplicit(ctx, fnRef, { argExpr },
3600-
{ Identifier() }, getType);
3596+
{ Identifier() });
36013597

36023598
bool invalid = tc.typeCheckExpression(callExpr, cs.DC,
36033599
TypeLoc::withoutLoc(valueType),
@@ -6037,11 +6033,12 @@ Expr *ExprRewriter::convertLiteral(Expr *literal,
60376033
cs.cacheExprTypes(base);
60386034
cs.setExprTypes(base);
60396035
cs.setExprTypes(literal);
6036+
SmallVector<Expr *, 1> arguments = { literal };
60406037

60416038
Expr *result = tc.callWitness(base, dc,
60426039
builtinProtocol, *builtinConformance,
60436040
builtinLiteralFuncName,
6044-
literal,
6041+
arguments,
60456042
brokenBuiltinProtocolDiag);
60466043
if (result)
60476044
cs.cacheExprTypes(result);
@@ -7230,6 +7227,9 @@ Expr *TypeChecker::callWitness(Expr *base, DeclContext *dc,
72307227
// Construct an empty constraint system and solution.
72317228
ConstraintSystem cs(*this, dc, ConstraintSystemOptions());
72327229

7230+
for (auto *arg : arguments)
7231+
cs.cacheType(arg);
7232+
72337233
// Find the witness we need to use.
72347234
auto type = base->getType();
72357235
assert(!type->hasTypeVariable() &&
@@ -7275,7 +7275,7 @@ Expr *TypeChecker::callWitness(Expr *base, DeclContext *dc,
72757275
auto argLabels = witness->getFullName().getArgumentNames();
72767276
if (arguments.size() == 1 &&
72777277
(isVariadicWitness(witness) ||
7278-
argumentNamesMatch(arguments[0]->getType(), argLabels))) {
7278+
argumentNamesMatch(cs.getType(arguments[0]), argLabels))) {
72797279
call = CallExpr::create(Context, unresolvedDot, arguments[0], {}, {},
72807280
/*hasTrailingClosure=*/false,
72817281
/*implicit=*/true, Type(), getType);

0 commit comments

Comments
 (0)