Merge pull request #38941 from xedin/improve-inout-variadic-inference-for-closures

[ConstraintSystem] Always propagate inout/variadic flags to type-less…
This commit is contained in:
Pavel Yaskevich
2021-08-20 09:51:53 -07:00
committed by GitHub

View File

@@ -8831,11 +8831,16 @@ bool ConstraintSystem::resolveClosure(TypeVariableType *typeVar,
auto param = inferredClosureType->getParams()[i];
auto *paramDecl = paramList->get(i);
// In case of anonymous parameters let's infer flags from context
// that helps to infer variadic and inout earlier.
if (closure->hasAnonymousClosureVars()) {
if (auto contextualParam = getContextualParamAt(i))
param = param.withFlags(contextualParam->getParameterFlags());
// In case of anonymous or name-only parameters, let's infer inout/variadic
// flags from context, that helps to propagate type information into the
// internal type of the parameter and reduces inference solver has to make.
if (!paramDecl->getTypeRepr()) {
if (auto contextualParam = getContextualParamAt(i)) {
auto flags = param.getParameterFlags();
param =
param.withFlags(flags.withInOut(contextualParam->isInOut())
.withVariadic(contextualParam->isVariadic()));
}
}
if (paramDecl->hasAttachedPropertyWrapper()) {