File tree Expand file tree Collapse file tree 2 files changed +11
-17
lines changed
Expand file tree Collapse file tree 2 files changed +11
-17
lines changed Original file line number Diff line number Diff line change @@ -335,6 +335,14 @@ void ConstraintSystem::PotentialBindings::finalize(
335335 if (locator->isLastElement <LocatorPathElt::MemberRefBase>())
336336 PotentiallyIncomplete = true ;
337337
338+ // Delay resolution of the code completion expression until
339+ // the very end to give it a chance to be bound to some
340+ // contextual type even if it's a hole.
341+ if (locator->directlyAt <CodeCompletionExpr>()) {
342+ FullyBound = true ;
343+ PotentiallyIncomplete = true ;
344+ }
345+
338346 addPotentialBinding (PotentialBinding::forHole (TypeVar, locator));
339347 }
340348
Original file line number Diff line number Diff line change @@ -1009,23 +1009,9 @@ namespace {
10091009 virtual Type visitCodeCompletionExpr (CodeCompletionExpr *E) {
10101010 CS.Options |= ConstraintSystemFlags::SuppressDiagnostics;
10111011 auto locator = CS.getConstraintLocator (E);
1012- auto ty = CS.createTypeVariable (locator,
1013- TVO_CanBindToLValue |
1014- TVO_CanBindToNoEscape);
1015-
1016- // Defaults to the type of the base expression if we have a base
1017- // expression.
1018- // FIXME: This is just to keep the old behavior where `foo(base.<HERE>)`
1019- // the argument is type checked to the type of the 'base'. Ideally, code
1020- // completion expression should be defauled to 'UnresolvedType'
1021- // regardless of the existence of the base expression. But the constraint
1022- // system is simply not ready for that.
1023- if (auto base = E->getBase ()) {
1024- CS.addConstraint (ConstraintKind::Defaultable, ty, CS.getType (base),
1025- locator);
1026- }
1027-
1028- return ty;
1012+ return CS.createTypeVariable (locator, TVO_CanBindToLValue |
1013+ TVO_CanBindToNoEscape |
1014+ TVO_CanBindToHole);
10291015 }
10301016
10311017 Type visitNilLiteralExpr (NilLiteralExpr *expr) {
You can’t perform that action at this time.
0 commit comments