Skip to content

[Constraint solver] Fix backward trailing closures with ".member" expressions #33721

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/Sema/CSApply.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5592,7 +5592,7 @@ Expr *ExprRewriter::coerceCallArguments(
SmallVector<LocatorPathElt, 4> path;
auto anchor = locator.getLocatorParts(path);
if (!path.empty() && path.back().is<LocatorPathElt::ApplyArgument>() &&
(anchor.isExpr(ExprKind::Call) || anchor.isExpr(ExprKind::Subscript))) {
!anchor.isExpr(ExprKind::UnresolvedDot)) {
auto locatorPtr = cs.getConstraintLocator(locator);
assert(solution.trailingClosureMatchingChoices.count(locatorPtr) == 1);
trailingClosureMatching = solution.trailingClosureMatchingChoices.find(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// RUN: %target-swift-emit-silgen %s | %FileCheck %s

// rdar://problem/67781123 - crash in SILGen

struct Foo {
var title: String
var handler1: ((Int, String) -> Void)?
var handler2: (() -> Void)?
}

func take(foo: Foo) { }

// CHECK-LABEL: sil hidden [ossa] @$s42forward_trailing_closure_unresolved_member4testyy
func test() {
// CHECK: function_ref @$s42forward_trailing_closure_unresolved_member4testyyFyycfU_ : $@convention(thin) () -> ()
take(foo: .init(title: "") {
print("handler2 is called")
})
}