@@ -59,8 +59,7 @@ using namespace constraints;
5959
6060static Type
6161getTypeOfExpressionWithoutApplying (Expr *&expr, DeclContext *dc,
62- ConcreteDeclRef &referencedDecl,
63- FreeTypeVariableBinding allowFreeTypeVariables) {
62+ ConcreteDeclRef &referencedDecl) {
6463 if (isa<AbstractClosureExpr>(dc)) {
6564 // If the expression is embedded in a closure, the constraint system tries
6665 // to retrieve that closure's type, which will fail since we won't have
@@ -95,15 +94,18 @@ getTypeOfExpressionWithoutApplying(Expr *&expr, DeclContext *dc,
9594 expr->setType (Type ());
9695 SyntacticElementTarget target (expr, dc, CTP_Unused, Type (),
9796 /* 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 ()) {
100102 recoverOriginalType ();
101103 return Type ();
102104 }
103105
104106 // Get the expression's simplified type.
105107 expr = target.getAsExpr ();
106- auto &solution = (* viable)[ 0 ] ;
108+ auto &solution = viable. front () ;
107109 auto &solutionCS = solution.getConstraintSystem ();
108110 Type exprType = solution.simplifyType (solutionCS.getType (expr));
109111
@@ -332,8 +334,8 @@ getTypeOfCompletionContextExpr(DeclContext *DC, CompletionTypeCheckKind kind,
332334 }
333335
334336 Type originalType = parsedExpr->getType ();
335- if (auto T = getTypeOfExpressionWithoutApplying (parsedExpr, DC,
336- referencedDecl, FreeTypeVariableBinding::UnresolvedType ))
337+ if (auto T =
338+ getTypeOfExpressionWithoutApplying (parsedExpr, DC, referencedDecl ))
337339 return T;
338340
339341 // Try to recover if we've made any progress.
0 commit comments