[CSSimplify] Avoid filtering init overloads of a callable type

If there is a call to `init` on a callable type that has a trailing
closure, let's avoid filtering because it's impossible to tell whether
a trailing closure belongs to an `init` call or implicit `.callAsFunction`
that would be attempted after it.

Resolves: rdar://92912878
This commit is contained in:
Pavel Yaskevich
2022-05-09 18:12:52 -07:00
parent f1d575170f
commit d81007cf08
2 changed files with 40 additions and 0 deletions

View File

@@ -10946,6 +10946,24 @@ bool ConstraintSystem::simplifyAppliedOverloadsImpl(
auto *argList = getArgumentList(getConstraintLocator(locator));
// If argument list has trailing closures and this is `init` call to
// a callable type, let's not filter anything since there is a possibility
// that it needs an implicit `.callAsFunction` to work.
if (argList && argList->hasAnyTrailingClosures()) {
if (disjunction->getLocator()
->isLastElement<LocatorPathElt::ConstructorMember>()) {
auto choice = disjunction->getNestedConstraints()[0]->getOverloadChoice();
if (auto *decl = choice.getDeclOrNull()) {
auto *dc = decl->getDeclContext();
if (auto *parent = dc->getSelfNominalTypeDecl()) {
auto type = parent->getDeclaredInterfaceType();
if (type->isCallableNominalType(DC))
return false;
}
}
}
}
// Consider each of the constraints in the disjunction.
retry_after_fail:
bool hasUnhandledConstraints = false;