mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user