Skip to content

Commit 6560c13

Browse files
authored
Merge pull request #60881 from xedin/issue-60586-5.7
[5.7][ConstraintSystem] Fix result builder discovery in leading-dot syntax calls
2 parents 15a3ff6 + 1580386 commit 6560c13

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9866,7 +9866,9 @@ static Type getOpenedResultBuilderTypeFor(ConstraintSystem &cs,
98669866
auto *calleeLocator = cs.getCalleeLocator(cs.getConstraintLocator(locator));
98679867
auto selectedOverload = cs.findSelectedOverloadFor(calleeLocator);
98689868
if (!(selectedOverload &&
9869-
selectedOverload->choice.getKind() == OverloadChoiceKind::Decl))
9869+
(selectedOverload->choice.getKind() == OverloadChoiceKind::Decl ||
9870+
selectedOverload->choice.getKind() ==
9871+
OverloadChoiceKind::DeclViaUnwrappedOptional)))
98709872
return Type();
98719873

98729874
auto *choice = selectedOverload->choice.getDecl();

test/Constraints/result_builder.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,3 +1198,19 @@ func test_callAsFunction_with_resultBuilder() {
11981198
test_callAsFunction_with_resultBuilder()
11991199
// CHECK: (0, "with parens", true)
12001200
// CHECK: (1, "without parens", true)
1201+
1202+
do {
1203+
struct S {
1204+
static func test<T>(@TupleBuilder _ body: (Bool) -> T) -> S {
1205+
print(body(true))
1206+
return .init()
1207+
}
1208+
}
1209+
1210+
let _: S? = .test {
1211+
42
1212+
""
1213+
[$0]
1214+
}
1215+
// CHECK: (42, "", [true])
1216+
}

0 commit comments

Comments
 (0)