From d675c7471bf866349d8b0820a88a2ea4d8c7e34c Mon Sep 17 00:00:00 2001 From: Pavel Yaskevich Date: Fri, 6 Nov 2020 17:56:19 -0800 Subject: [PATCH] [CSApply] Adjust @autoclosure locator to point to argument expression being coerced to result type While applying type inferred for autoclosure to argument use locator that records argument/param indices to make it possible for `coerceToType` to simplify it down to underlying argument expression if necessary. --- lib/Sema/CSApply.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/Sema/CSApply.cpp b/lib/Sema/CSApply.cpp index 2b08dda1cd2bb..437481c310d4a 100644 --- a/lib/Sema/CSApply.cpp +++ b/lib/Sema/CSApply.cpp @@ -5813,9 +5813,11 @@ Expr *ExprRewriter::coerceCallArguments( // - new types are propagated to constraint system auto *closureType = param.getPlainType()->castTo(); + auto argLoc = getArgLocator(argIdx, paramIdx, param.getParameterFlags()); + arg = coerceToType( arg, closureType->getResult(), - locator.withPathElement(ConstraintLocator::AutoclosureResult)); + argLoc.withPathElement(ConstraintLocator::AutoclosureResult)); if (shouldInjectWrappedValuePlaceholder) { // If init(wrappedValue:) takes an autoclosure, then we want