File tree Expand file tree Collapse file tree 3 files changed +19
-3
lines changed Expand file tree Collapse file tree 3 files changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -9495,6 +9495,12 @@ bool IsFunctionBodySkippedRequest::evaluate(
9495
9495
skippingMode == FunctionBodySkipping::NonInlinableWithoutTypes)
9496
9496
return false ;
9497
9497
9498
+ // Don't skip functions that follow a top-level guard statement.
9499
+ if (afd->getDeclContext ()->isModuleScopeContext () &&
9500
+ isa<FuncDecl>(afd) &&
9501
+ cast<FuncDecl>(afd)->hasTopLevelLocalContextCaptures ())
9502
+ return false ;
9503
+
9498
9504
// Skip functions that don't need to be serialized.
9499
9505
return afd->getResilienceExpansion () != ResilienceExpansion::Minimal;
9500
9506
}
Original file line number Diff line number Diff line change
1
+ // RUN: %target-swift-frontend -experimental-skip-non-inlinable-function-bodies-without-types -emit-module %s
2
+
3
+ let s : Int ? = nil
4
+ guard let m = s else { fatalError ( ) }
5
+
6
+ let x = m
7
+
8
+ public func f( _: Int = m, _: String = " " ) { }
9
+
10
+ f ( )
Original file line number Diff line number Diff line change 5
5
guard let x: Int = nil else { while true { } }
6
6
7
7
// 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) -> () {
8
+ // SKIPPED-FUNC-EMITTED-LABEL: sil hidden [ossa] @$s18top_level_captures0C1XyyF : $@convention(thin) (Int) -> () {
9
9
func capturesX( ) {
10
10
_ = x
11
11
}
12
12
13
13
// CHECK-LABEL: sil hidden [ossa] @$s18top_level_captures17transitiveCaptureyyF : $@convention(thin) (Int) -> () {
14
14
// 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) -> ()
15
+ // SKIPPED-FUNC-EMITTED-LABEL: sil hidden [ossa] @$s18top_level_captures17transitiveCaptureyyF : $@convention(thin) (Int) -> () {
16
+ // SKIPPED-FUNC-EMITTED: [[FUNC:%.*]] = function_ref @$s18top_level_captures0C1XyyF : $@convention(thin) (Int) -> ()
17
17
func transitiveCapture( ) {
18
18
capturesX ( )
19
19
}
You can’t perform that action at this time.
0 commit comments