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