@@ -59,8 +59,7 @@ using namespace constraints;
59
59
60
60
static Type
61
61
getTypeOfExpressionWithoutApplying (Expr *&expr, DeclContext *dc,
62
- ConcreteDeclRef &referencedDecl,
63
- FreeTypeVariableBinding allowFreeTypeVariables) {
62
+ ConcreteDeclRef &referencedDecl) {
64
63
if (isa<AbstractClosureExpr>(dc)) {
65
64
// If the expression is embedded in a closure, the constraint system tries
66
65
// to retrieve that closure's type, which will fail since we won't have
@@ -95,15 +94,18 @@ getTypeOfExpressionWithoutApplying(Expr *&expr, DeclContext *dc,
95
94
expr->setType (Type ());
96
95
SyntacticElementTarget target (expr, dc, CTP_Unused, Type (),
97
96
/* isDiscarded=*/ false );
98
- auto viable = cs.solve (target, allowFreeTypeVariables);
99
- if (!viable) {
97
+
98
+ SmallVector<Solution, 2 > viable;
99
+ cs.solveForCodeCompletion (target, viable);
100
+
101
+ if (viable.empty ()) {
100
102
recoverOriginalType ();
101
103
return Type ();
102
104
}
103
105
104
106
// Get the expression's simplified type.
105
107
expr = target.getAsExpr ();
106
- auto &solution = (* viable)[ 0 ] ;
108
+ auto &solution = viable. front () ;
107
109
auto &solutionCS = solution.getConstraintSystem ();
108
110
Type exprType = solution.simplifyType (solutionCS.getType (expr));
109
111
@@ -332,8 +334,8 @@ getTypeOfCompletionContextExpr(DeclContext *DC, CompletionTypeCheckKind kind,
332
334
}
333
335
334
336
Type originalType = parsedExpr->getType ();
335
- if (auto T = getTypeOfExpressionWithoutApplying (parsedExpr, DC,
336
- referencedDecl, FreeTypeVariableBinding::UnresolvedType ))
337
+ if (auto T =
338
+ getTypeOfExpressionWithoutApplying (parsedExpr, DC, referencedDecl ))
337
339
return T;
338
340
339
341
// Try to recover if we've made any progress.
0 commit comments