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(
335
335
if (locator->isLastElement <LocatorPathElt::MemberRefBase>())
336
336
PotentiallyIncomplete = true ;
337
337
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
+
338
346
addPotentialBinding (PotentialBinding::forHole (TypeVar, locator));
339
347
}
340
348
Original file line number Diff line number Diff line change @@ -1009,23 +1009,9 @@ namespace {
1009
1009
virtual Type visitCodeCompletionExpr (CodeCompletionExpr *E) {
1010
1010
CS.Options |= ConstraintSystemFlags::SuppressDiagnostics;
1011
1011
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);
1029
1015
}
1030
1016
1031
1017
Type visitNilLiteralExpr (NilLiteralExpr *expr) {
You can’t perform that action at this time.
0 commit comments