@@ -1476,9 +1476,10 @@ namespace {
1476
1476
(ConformanceCheckFlags::InExpression|
1477
1477
ConformanceCheckFlags::Used))) {
1478
1478
// Form the call.
1479
- return tc.callWitness (value, cs.DC , bridgedProto, *conformance,
1480
- tc.Context .Id_bridgeToObjectiveC ,
1481
- { }, diag::broken_bridged_to_objc_protocol);
1479
+ return cs.cacheType (
1480
+ tc.callWitness (value, cs.DC , bridgedProto, *conformance,
1481
+ tc.Context .Id_bridgeToObjectiveC ,
1482
+ { }, diag::broken_bridged_to_objc_protocol));
1482
1483
}
1483
1484
1484
1485
// If there is an Error conformance, try bridging as an error.
@@ -2066,8 +2067,9 @@ namespace {
2066
2067
2067
2068
// Build a reference to the init(stringInterpolation:) initializer.
2068
2069
// FIXME: This location info is bogus.
2069
- auto typeRef = TypeExpr::createImplicitHack (expr->getStartLoc (),
2070
- type, tc.Context );
2070
+ auto *typeRef =
2071
+ cs.cacheType (TypeExpr::createImplicitHack (expr->getStartLoc (),
2072
+ type, tc.Context ));
2071
2073
Expr *memberRef =
2072
2074
new (tc.Context ) MemberRefExpr (typeRef,
2073
2075
expr->getStartLoc (),
@@ -2107,6 +2109,7 @@ namespace {
2107
2109
tc.Context , memberRef,
2108
2110
{ segment },
2109
2111
{ tc.Context .Id_stringInterpolationSegment });
2112
+ cs.cacheType (apply->getArg ());
2110
2113
2111
2114
auto converted = finishApply (apply, openedType, locatorBuilder);
2112
2115
if (!converted)
@@ -4640,15 +4643,17 @@ Expr *ExprRewriter::coerceOptionalToOptional(Expr *expr, Type toType,
4640
4643
}
4641
4644
}
4642
4645
4643
- expr = new (tc.Context ) BindOptionalExpr (expr, expr->getSourceRange ().End ,
4644
- /* depth*/ 0 , fromValueType);
4646
+ expr =
4647
+ cs.cacheType (new (tc.Context ) BindOptionalExpr (expr,
4648
+ expr->getSourceRange ().End ,
4649
+ /* depth*/ 0 , fromValueType));
4645
4650
expr->setImplicit (true );
4646
4651
expr = coerceToType (expr, toValueType, locator, typeFromPattern);
4647
4652
if (!expr) return nullptr ;
4648
4653
4649
- expr = new (tc.Context ) InjectIntoOptionalExpr (expr, toType);
4654
+ expr = cs. cacheType ( new (tc.Context ) InjectIntoOptionalExpr (expr, toType) );
4650
4655
4651
- expr = new (tc.Context ) OptionalEvaluationExpr (expr, toType);
4656
+ expr = cs. cacheType ( new (tc.Context ) OptionalEvaluationExpr (expr, toType) );
4652
4657
expr->setImplicit (true );
4653
4658
return expr;
4654
4659
}
@@ -4957,12 +4962,13 @@ Expr *ExprRewriter::coerceCallArguments(
4957
4962
if (anyChanged || !cs.getType (argTuple)->isEqual (argTupleType)) {
4958
4963
auto EltNames = argTuple->getElementNames ();
4959
4964
auto EltNameLocs = argTuple->getElementNameLocs ();
4960
- argTuple = TupleExpr::create (tc.Context , argTuple->getLParenLoc (),
4961
- fromTupleExpr, EltNames, EltNameLocs,
4962
- argTuple->getRParenLoc (),
4963
- argTuple->hasTrailingClosure (),
4964
- argTuple->isImplicit (),
4965
- argTupleType);
4965
+ argTuple =
4966
+ cs.cacheType (TupleExpr::create (tc.Context , argTuple->getLParenLoc (),
4967
+ fromTupleExpr, EltNames, EltNameLocs,
4968
+ argTuple->getRParenLoc (),
4969
+ argTuple->hasTrailingClosure (),
4970
+ argTuple->isImplicit (),
4971
+ argTupleType));
4966
4972
arg = argTuple;
4967
4973
}
4968
4974
}
@@ -5937,8 +5943,9 @@ Expr *ExprRewriter::convertLiteral(Expr *literal,
5937
5943
5938
5944
// Convert the resulting expression to the final literal type.
5939
5945
// FIXME: Bogus location info.
5940
- Expr *base = TypeExpr::createImplicitHack (literal->getLoc (), type,
5941
- tc.Context );
5946
+ Expr *base =
5947
+ cs.cacheType (TypeExpr::createImplicitHack (literal->getLoc (), type,
5948
+ tc.Context ));
5942
5949
literal = tc.callWitness (base, dc,
5943
5950
protocol, *conformance, literalFuncName,
5944
5951
literal, brokenProtocolDiag);
@@ -5989,8 +5996,9 @@ Expr *ExprRewriter::convertLiteralInPlace(Expr *literal,
5989
5996
5990
5997
// Form a reference to the builtin conversion function.
5991
5998
// FIXME: Bogus location info.
5992
- Expr *base = TypeExpr::createImplicitHack (literal->getLoc (), type,
5993
- tc.Context );
5999
+ Expr *base =
6000
+ cs.cacheType (TypeExpr::createImplicitHack (literal->getLoc (), type,
6001
+ tc.Context ));
5994
6002
Expr *unresolvedDot = new (tc.Context ) UnresolvedDotExpr (
5995
6003
base, SourceLoc (),
5996
6004
witness->getFullName (),
@@ -6917,6 +6925,9 @@ Expr *TypeChecker::callWitness(Expr *base, DeclContext *dc,
6917
6925
ConstraintSystem cs (*this , dc, ConstraintSystemOptions ());
6918
6926
6919
6927
cs.cacheExprTypes (base);
6928
+ for (auto *e : arguments) {
6929
+ cs.cacheExprTypes (e);
6930
+ }
6920
6931
6921
6932
// Find the witness we need to use.
6922
6933
auto type = cs.getType (base);
0 commit comments