Skip to content

Commit b62328b

Browse files
authored
Merge pull request #33721 from DougGregor/forward-scan-unresolved-member
[Constraint solver] Fix backward trailing closures with ".member" expressions
2 parents 8fb8178 + cabcbc9 commit b62328b

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

lib/Sema/CSApply.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5572,7 +5572,7 @@ Expr *ExprRewriter::coerceCallArguments(
55725572
SmallVector<LocatorPathElt, 4> path;
55735573
auto anchor = locator.getLocatorParts(path);
55745574
if (!path.empty() && path.back().is<LocatorPathElt::ApplyArgument>() &&
5575-
(anchor.isExpr(ExprKind::Call) || anchor.isExpr(ExprKind::Subscript))) {
5575+
!anchor.isExpr(ExprKind::UnresolvedDot)) {
55765576
auto locatorPtr = cs.getConstraintLocator(locator);
55775577
assert(solution.trailingClosureMatchingChoices.count(locatorPtr) == 1);
55785578
trailingClosureMatching = solution.trailingClosureMatchingChoices.find(
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// RUN: %target-swift-emit-silgen %s | %FileCheck %s
2+
3+
// rdar://problem/67781123 - crash in SILGen
4+
5+
struct Foo {
6+
var title: String
7+
var handler1: ((Int, String) -> Void)?
8+
var handler2: (() -> Void)?
9+
}
10+
11+
func take(foo: Foo) { }
12+
13+
// CHECK-LABEL: sil hidden [ossa] @$s42forward_trailing_closure_unresolved_member4testyy
14+
func test() {
15+
// CHECK: function_ref @$s42forward_trailing_closure_unresolved_member4testyyFyycfU_ : $@convention(thin) () -> ()
16+
take(foo: .init(title: "") {
17+
print("handler2 is called")
18+
})
19+
}

0 commit comments

Comments
 (0)