Skip to content

Commit 8252ce7

Browse files
authored
Merge pull request #59109 from CodaFi/hidden-variables
[5.7] Handle ParamDecls and VarDecls in Argument Matching Diagnostics
2 parents 0eec075 + 70557f0 commit 8252ce7

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4899,9 +4899,13 @@ bool ConstraintSystem::repairFailures(
48994899
if (!(overload && overload->choice.isDecl()))
49004900
return true;
49014901

4902-
if (!getParameterList(overload->choice.getDecl())
4903-
->get(applyLoc->getParamIdx())
4904-
->getTypeOfDefaultExpr())
4902+
// Ignore decls that don't have meaningful parameter lists - this
4903+
// matches variables and parameters with function types.
4904+
auto *paramList = getParameterList(overload->choice.getDecl());
4905+
if (!paramList)
4906+
return true;
4907+
4908+
if (!paramList->get(applyLoc->getParamIdx())->getTypeOfDefaultExpr())
49054909
return true;
49064910
}
49074911
}

test/Constraints/argument_matching.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1782,3 +1782,10 @@ func testExtraTrailingClosure() {
17821782
func qux(x: () -> Void, y: () -> Void, z: () -> Void) {} // expected-note {{'qux(x:y:z:)' declared here}}
17831783
qux() {} m: {} y: {} n: {} z: {} o: {} // expected-error@:6 {{extra trailing closures at positions #2, #4, #6 in call}}
17841784
}
1785+
1786+
// rdar://93922410 - argument-to-parameter doesn't handle applies of ParamDecls
1787+
func rdar93922410(_ completion: (Int?) -> Void) { // expected-note {{'completion' declared here}}
1788+
_ = {
1789+
return completion() // expected-error {{missing argument for parameter #1 in call}}
1790+
}
1791+
}

0 commit comments

Comments
 (0)