Skip to content

Commit 01c295d

Browse files
authored
Merge pull request #58793 from xedin/rdar-92914226
[ConstraintSystem] Adjust `getCalleeLocator` to handle implicit `call…
2 parents 04d873d + f7c4ff6 commit 01c295d

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

lib/Sema/ConstraintSystem.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,13 @@ ConstraintLocator *ConstraintSystem::getCalleeLocator(
564564
}
565565

566566
if (auto *UDE = getAsExpr<UnresolvedDotExpr>(anchor)) {
567+
if (UDE->isImplicit() &&
568+
UDE->getName().getBaseName() == Context.Id_callAsFunction) {
569+
return getConstraintLocator(anchor,
570+
{LocatorPathElt::ApplyFunction(),
571+
LocatorPathElt::ImplicitCallAsFunction()});
572+
}
573+
567574
return getConstraintLocator(
568575
anchor, TypeChecker::getSelfForInitDelegationInConstructor(DC, UDE)
569576
? ConstraintLocator::ConstructorMember

test/Constraints/result_builder.swift

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,3 +1174,27 @@ let list3 = list {
11741174
}
11751175
print(list3)
11761176
// CHECK: (cons "4" (cons (cons "3" (cons 2.0 nil)) (cons 1 nil)))
1177+
1178+
func test_callAsFunction_with_resultBuilder() {
1179+
struct CallableTest {
1180+
func callAsFunction<T>(@TupleBuilder _ body: (Bool) -> T) {
1181+
print(body(true))
1182+
}
1183+
}
1184+
1185+
CallableTest() {
1186+
0
1187+
"with parens"
1188+
$0
1189+
}
1190+
1191+
CallableTest {
1192+
1
1193+
"without parens"
1194+
$0
1195+
}
1196+
}
1197+
1198+
test_callAsFunction_with_resultBuilder()
1199+
// CHECK: (0, "with parens", true)
1200+
// CHECK: (1, "without parens", true)

0 commit comments

Comments
 (0)