Skip to content

Commit eca51d4

Browse files
committed
Fix keypath-as-function crasher
The autoclosures generated for the keypath-as-function feature were not added to the list of closures that needed captures computed. In top-level code, this caused a crash. Fixes rdar://problem/56055600.
1 parent 1a1f731 commit eca51d4

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

lib/AST/CaptureInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ getLocalCaptures(SmallVectorImpl<CapturedValue> &Result) const {
7878
}
7979
}
8080

81-
void CaptureInfo::dump() const {
81+
LLVM_ATTRIBUTE_USED void CaptureInfo::dump() const {
8282
print(llvm::errs());
8383
llvm::errs() << '\n';
8484
}

lib/Sema/CSApply.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4500,6 +4500,10 @@ namespace {
45004500
outerClosure->setType(outerClosureTy);
45014501
cs.cacheType(outerClosure);
45024502

4503+
// The inner closure at least will definitely have a capture.
4504+
cs.TC.ClosuresWithUncomputedCaptures.push_back(outerClosure);
4505+
cs.TC.ClosuresWithUncomputedCaptures.push_back(closure);
4506+
45034507
// let outerApply = "\( outerClosure )( \(E) )"
45044508
auto outerApply = CallExpr::createImplicit(ctx, outerClosure, {E}, {});
45054509
outerApply->setType(closureTy);
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// RUN: %target-swift-frontend %s -emit-silgen -o /dev/null
2+
let _: ([Int]) -> Int = \[Int].count

0 commit comments

Comments
 (0)