Skip to content

Commit 276e1a2

Browse files
authored
Merge pull request swiftlang#34989 from xedin/rdar-71525503
[ConstraintSystem] Adjust `getFunctionArgApplyInfo` to respect holes
2 parents 611ff41 + a046eaf commit 276e1a2

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

lib/Sema/ConstraintSystem.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4413,9 +4413,16 @@ Solution::getFunctionArgApplyInfo(ConstraintLocator *locator) const {
44134413
// If we didn't resolve an overload for the callee, we should be dealing
44144414
// with a call of an arbitrary function expr.
44154415
auto *call = castToExpr<CallExpr>(anchor);
4416+
rawFnType = getType(call->getFn());
4417+
4418+
// If callee couldn't be resolved due to expression
4419+
// issues e.g. it's a reference to an invalid member
4420+
// let's just return here.
4421+
if (simplifyType(rawFnType)->is<UnresolvedType>())
4422+
return None;
4423+
44164424
assert(!shouldHaveDirectCalleeOverload(call) &&
44174425
"Should we have resolved a callee for this?");
4418-
rawFnType = getType(call->getFn());
44194426
}
44204427

44214428
// Try to resolve the function type by loading lvalues and looking through

test/Constraints/closures.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,3 +1042,17 @@ let explicitUnboundResult2: (Array<Bool>) -> Array<Int> = {
10421042
let explicitUnboundResult3: (Array<Bool>) -> Array<Int> = {
10431043
(arr: Array) -> Array in [true]
10441044
}
1045+
1046+
// rdar://problem/71525503 - Assertion failed: (!shouldHaveDirectCalleeOverload(call) && "Should we have resolved a callee for this?")
1047+
func test_inout_with_invalid_member_ref() {
1048+
struct S {
1049+
static func createS(_ arg: inout Int) -> S { S() }
1050+
}
1051+
class C {
1052+
static subscript(s: (Int) -> Void) -> Bool { get { return false } }
1053+
}
1054+
1055+
let _: Bool = C[{ .createS(&$0) }]
1056+
// expected-error@-1 {{value of tuple type 'Void' has no member 'createS'}}
1057+
// expected-error@-2 {{cannot pass immutable value as inout argument: '$0' is immutable}}
1058+
}

0 commit comments

Comments
 (0)