Skip to content

Commit f40b9b6

Browse files
[Sema] Minor adjusting on RemoveExtraneousArguments record logic
1 parent c1f43c8 commit f40b9b6

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4353,15 +4353,14 @@ bool ConstraintSystem::repairFailures(
43534353
if (rhs->is<TupleType>() && closureAnchor &&
43544354
closureAnchor->getParameters()->size() > 1) {
43554355
auto callee = getCalleeLocator(loc);
4356-
auto overload = findSelectedOverloadFor(callee);
4357-
if (overload) {
4358-
auto fnType = overload->openedType->getAs<FunctionType>();
4356+
if (auto overload = findSelectedOverloadFor(callee)) {
4357+
auto fnType =
4358+
simplifyType(overload->openedType)->castTo<FunctionType>();
43594359
auto paramIdx = argToParamElt->getParamIdx();
4360-
if (auto paramType = fnType->getParams()[paramIdx]
4361-
.getOldType()
4362-
->getAs<FunctionType>()) {
4363-
conversionsOrFixes.push_back(
4364-
RemoveExtraneousArguments::create(*this, paramType, {}, loc));
4360+
auto paramType = fnType->getParams()[paramIdx].getParameterType();
4361+
if (auto paramFnType = paramType->getAs<FunctionType>()) {
4362+
conversionsOrFixes.push_back(RemoveExtraneousArguments::create(
4363+
*this, paramFnType, {}, loc));
43654364
break;
43664365
}
43674366
}

test/Constraints/closures.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,8 +1100,8 @@ struct R_76250381<Result, Failure: Error> {
11001100

11011101
// SR-13483
11021102
(0..<10).map { x, y in }
1103-
// expected-error@-1 {{contextual closure type '((Range<Int>).Element) throws -> ()' expects 1 argument, but 2 were used in closure body}}
1103+
// expected-error@-1 {{contextual closure type '(Range<Int>.Element) throws -> ()' (aka '(Int) throws -> ()') expects 1 argument, but 2 were used in closure body}}
11041104
(0..<10).map { x, y, z in }
1105-
// expected-error@-1 {{contextual closure type '((Range<Int>).Element) throws -> ()' expects 1 argument, but 3 were used in closure body}}
1105+
// expected-error@-1 {{contextual closure type '(Range<Int>.Element) throws -> ()' (aka '(Int) throws -> ()') expects 1 argument, but 3 were used in closure body}}
11061106
(0..<10).map { x, y, z, w in }
1107-
// expected-error@-1 {{contextual closure type '((Range<Int>).Element) throws -> ()' expects 1 argument, but 4 were used in closure body}}
1107+
// expected-error@-1 {{contextual closure type '(Range<Int>.Element) throws -> ()' (aka '(Int) throws -> ()') expects 1 argument, but 4 were used in closure body}}

0 commit comments

Comments
 (0)