Skip to content

Commit c9ddfbc

Browse files
authored
Merge pull request #59090 from CodaFi/unknown-unknowns
Handle ParamDecls and VarDecls in Argument Matching Diagnostics
2 parents 7d8af2d + 174bbd2 commit c9ddfbc

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
@@ -4896,9 +4896,13 @@ bool ConstraintSystem::repairFailures(
48964896
if (!(overload && overload->choice.isDecl()))
48974897
return true;
48984898

4899-
if (!getParameterList(overload->choice.getDecl())
4900-
->get(applyLoc->getParamIdx())
4901-
->getTypeOfDefaultExpr())
4899+
// Ignore decls that don't have meaningful parameter lists - this
4900+
// matches variables and parameters with function types.
4901+
auto *paramList = getParameterList(overload->choice.getDecl());
4902+
if (!paramList)
4903+
return true;
4904+
4905+
if (!paramList->get(applyLoc->getParamIdx())->getTypeOfDefaultExpr())
49024906
return true;
49034907
}
49044908
}

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)