Skip to content

Commit fd5622e

Browse files
authored
Merge pull request #60597 from xedin/rdar-98304482-5.7
[5.7][ConstraintSystem] Don't produce argument info object for extraneous …
2 parents fb5d544 + 065e9bd commit fd5622e

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

include/swift/Sema/ConstraintSystem.h

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,14 +645,30 @@ class FunctionArgApplyInfo {
645645
FunctionType *FnType;
646646
const ValueDecl *Callee;
647647

648-
public:
649648
FunctionArgApplyInfo(ArgumentList *argList, Expr *argExpr, unsigned argIdx,
650649
Type argType, unsigned paramIdx, Type fnInterfaceType,
651650
FunctionType *fnType, const ValueDecl *callee)
652651
: ArgList(argList), ArgExpr(argExpr), ArgIdx(argIdx), ArgType(argType),
653652
ParamIdx(paramIdx), FnInterfaceType(fnInterfaceType), FnType(fnType),
654653
Callee(callee) {}
655654

655+
public:
656+
static Optional<FunctionArgApplyInfo>
657+
get(ArgumentList *argList, Expr *argExpr, unsigned argIdx, Type argType,
658+
unsigned paramIdx, Type fnInterfaceType, FunctionType *fnType,
659+
const ValueDecl *callee) {
660+
assert(fnType);
661+
662+
if (argIdx >= argList->size())
663+
return None;
664+
665+
if (paramIdx >= fnType->getNumParams())
666+
return None;
667+
668+
return FunctionArgApplyInfo(argList, argExpr, argIdx, argType, paramIdx,
669+
fnInterfaceType, fnType, callee);
670+
}
671+
656672
/// \returns The list of the arguments used for this application.
657673
ArgumentList *getArgList() const { return ArgList; }
658674

lib/Sema/ConstraintSystem.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5619,9 +5619,9 @@ Solution::getFunctionArgApplyInfo(ConstraintLocator *locator) const {
56195619
auto argIdx = applyArgElt->getArgIdx();
56205620
auto paramIdx = applyArgElt->getParamIdx();
56215621

5622-
return FunctionArgApplyInfo(argList, argExpr, argIdx,
5623-
simplifyType(getType(argExpr)), paramIdx,
5624-
fnInterfaceType, fnType, callee);
5622+
return FunctionArgApplyInfo::get(argList, argExpr, argIdx,
5623+
simplifyType(getType(argExpr)), paramIdx,
5624+
fnInterfaceType, fnType, callee);
56255625
}
56265626

56275627
bool constraints::isKnownKeyPathType(Type type) {

test/Constraints/argument_matching.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1789,3 +1789,11 @@ func rdar93922410(_ completion: (Int?) -> Void) { // expected-note {{'completion
17891789
return completion() // expected-error {{missing argument for parameter #1 in call}}
17901790
}
17911791
}
1792+
1793+
// https://github.com/apple/swift/issues/60436
1794+
func test_extraneous_argument_with_inout() {
1795+
func test(_: Int) {}
1796+
1797+
var x: Int = 0
1798+
test(42, &x) // expected-error {{extra argument in call}}
1799+
}

0 commit comments

Comments
 (0)