Skip to content

Commit b4fe5df

Browse files
committed
[CS] Avoid introducing Void closure result binding for hole
If we have a hole binding for the result of a closure, avoid introducing Void as an additional binding since that'll just cause local solution ambiguities. This doesn't affect regular type-checking since we end up treating such ambiguities as "identical", so we just pick one. But for completion, we don't do such filtering so need to make sure we end up with the hole solution to avoid treating Void as the contextual type for cases such as: ``` _ = { x.#^CC^# } ``` Currently we avoid this by not handling holes in `repairFailures` for closure body locators, but I'm changing that in the next commit.
1 parent 23ee6fb commit b4fe5df

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/Sema/CSBindings.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2681,8 +2681,11 @@ bool TypeVarBindingProducer::computeNext() {
26812681
// let's have it try `Void` as well because there is an
26822682
// implicit conversion `() -> T` to `() -> Void` and this
26832683
// helps to avoid creating a thunk to support it.
2684+
// Avoid doing this is we already have a hole binding since
2685+
// introducing Void will just cause local solution ambiguities.
26842686
if (getLocator()->isLastElement<LocatorPathElt::ClosureResult>() &&
2685-
binding.Kind == AllowedBindingKind::Supertypes) {
2687+
binding.Kind == AllowedBindingKind::Supertypes &&
2688+
!binding.BindingType->isPlaceholder()) {
26862689
auto voidType = CS.getASTContext().TheEmptyTupleType;
26872690
addNewBinding(binding.withSameSource(voidType, BindingKind::Exact));
26882691
}

0 commit comments

Comments
 (0)