Skip to content

Commit be35394

Browse files
authored
Merge pull request #70835 from jkshtj/main
Skip setting type expansion context for captures of skipped functions
2 parents 6abaf21 + 580e83e commit be35394

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

lib/SILGen/SILGen.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1437,14 +1437,14 @@ void SILGenModule::emitAbstractFuncDecl(AbstractFunctionDecl *AFD) {
14371437
void SILGenModule::emitFunction(FuncDecl *fd) {
14381438
assert(!shouldSkipDecl(fd));
14391439

1440-
Types.setCaptureTypeExpansionContext(SILDeclRef(fd), M);
1441-
14421440
SILDeclRef::Loc decl = fd;
14431441

14441442
emitAbstractFuncDecl(fd);
14451443

1446-
if (shouldEmitFunctionBody(fd))
1444+
if (shouldEmitFunctionBody(fd)) {
1445+
Types.setCaptureTypeExpansionContext(SILDeclRef(fd), M);
14471446
emitOrDelayFunction(SILDeclRef(decl));
1447+
}
14481448
}
14491449

14501450
void SILGenModule::addGlobalVariable(VarDecl *global) {

test/SILGen/top_level_captures.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
// RUN: %target-swift-frontend -emit-silgen %s | %FileCheck %s
22
// RUN: %target-swift-frontend -enable-experimental-async-top-level -emit-silgen %s | %FileCheck %s
3+
// RUN: %target-swift-frontend -experimental-skip-non-inlinable-function-bodies -experimental-skip-non-inlinable-function-bodies-without-types -emit-silgen %s | %FileCheck -check-prefix=SKIPPED-FUNC-EMITTED %s
34

45
guard let x: Int = nil else { while true { } }
56

67
// CHECK-LABEL: sil hidden [ossa] @$s18top_level_captures0C1XyyF : $@convention(thin) (Int) -> () {
8+
// SKIPPED-FUNC-EMITTED-LABEL-NOT: sil hidden [ossa] @$s18top_level_captures0C1XyyF : $@convention(thin) (Int) -> () {
79
func capturesX() {
810
_ = x
911
}
1012

1113
// CHECK-LABEL: sil hidden [ossa] @$s18top_level_captures17transitiveCaptureyyF : $@convention(thin) (Int) -> () {
1214
// CHECK: [[FUNC:%.*]] = function_ref @$s18top_level_captures0C1XyyF : $@convention(thin) (Int) -> ()
15+
// SKIPPED-FUNC-EMITTED-LABEL-NOT: sil hidden [ossa] @$s18top_level_captures17transitiveCaptureyyF : $@convention(thin) (Int) -> () {
16+
// SKIPPED-FUNC-EMITTED-NOT: [[FUNC:%.*]] = function_ref @$s18top_level_captures0C1XyyF : $@convention(thin) (Int) -> ()
1317
func transitiveCapture() {
1418
capturesX()
1519
}

0 commit comments

Comments
 (0)