Skip to content

Commit d5b30a6

Browse files
authored
Merge pull request #38941 from xedin/improve-inout-variadic-inference-for-closures
[ConstraintSystem] Always propagate inout/variadic flags to type-less…
2 parents ceb36c7 + 2aa98eb commit d5b30a6

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8831,11 +8831,16 @@ bool ConstraintSystem::resolveClosure(TypeVariableType *typeVar,
88318831
auto param = inferredClosureType->getParams()[i];
88328832
auto *paramDecl = paramList->get(i);
88338833

8834-
// In case of anonymous parameters let's infer flags from context
8835-
// that helps to infer variadic and inout earlier.
8836-
if (closure->hasAnonymousClosureVars()) {
8837-
if (auto contextualParam = getContextualParamAt(i))
8838-
param = param.withFlags(contextualParam->getParameterFlags());
8834+
// In case of anonymous or name-only parameters, let's infer inout/variadic
8835+
// flags from context, that helps to propagate type information into the
8836+
// internal type of the parameter and reduces inference solver has to make.
8837+
if (!paramDecl->getTypeRepr()) {
8838+
if (auto contextualParam = getContextualParamAt(i)) {
8839+
auto flags = param.getParameterFlags();
8840+
param =
8841+
param.withFlags(flags.withInOut(contextualParam->isInOut())
8842+
.withVariadic(contextualParam->isVariadic()));
8843+
}
88398844
}
88408845

88418846
if (paramDecl->hasAttachedPropertyWrapper()) {

0 commit comments

Comments
 (0)