@@ -140,6 +140,25 @@ bool PotentialBindings::isPotentiallyIncomplete() const {
140
140
if (!locator)
141
141
return false ;
142
142
143
+ if (locator->isLastElement <LocatorPathElt::MemberRefBase>() &&
144
+ !Bindings.empty ()) {
145
+ // If the base of the unresolved member reference like `.foo`
146
+ // couldn't be resolved we'd want to bind it to a hole at the
147
+ // very last moment possible, just like generic parameters.
148
+ if (isHole ())
149
+ return true ;
150
+
151
+ auto &binding = Bindings.front ();
152
+ // If base type of a member chain is inferred to be a protocol type,
153
+ // let's consider this binding set to be potentially incomplete since
154
+ // that's done as a last resort effort at resolving first member.
155
+ if (auto *constraint = binding.getSource ()) {
156
+ if (binding.BindingType ->is <ProtocolType>() &&
157
+ constraint->getKind () == ConstraintKind::ConformsTo)
158
+ return true ;
159
+ }
160
+ }
161
+
143
162
if (locator->isLastElement <LocatorPathElt::UnresolvedMemberChainResult>()) {
144
163
// If subtyping is allowed and this is a result of an implicit member chain,
145
164
// let's delay binding it to an optional until its object type resolved too or
@@ -159,12 +178,6 @@ bool PotentialBindings::isPotentiallyIncomplete() const {
159
178
}
160
179
161
180
if (isHole ()) {
162
- // If the base of the unresolved member reference like `.foo`
163
- // couldn't be resolved we'd want to bind it to a hole at the
164
- // very last moment possible, just like generic parameters.
165
- if (locator->isLastElement <LocatorPathElt::MemberRefBase>())
166
- return true ;
167
-
168
181
// Delay resolution of the code completion expression until
169
182
// the very end to give it a chance to be bound to some
170
183
// contextual type even if it's a hole.
@@ -428,7 +441,6 @@ void PotentialBindings::finalize(
428
441
{protocolTy, AllowedBindingKind::Exact, constraint});
429
442
}
430
443
431
- PotentiallyIncomplete = true ;
432
444
FullyBound = true ;
433
445
}
434
446
}
0 commit comments