File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change 1+ // RUN: %empty-directory(%t)
2+ // RUN: %target-swift-frontend -enable-experimental-feature Embedded -parse-as-library %s -c -o %t/a.o
3+ // RUN: %target-clang %t/a.o -o %t/a.out -L%swift_obj_root/lib/swift/embedded/%target-cpu-apple-macos -lswift_Concurrency -lswift_ConcurrencyDefaultExecutor -dead_strip
4+ // RUN: %target-run %t/a.out | %FileCheck %s
5+
6+ // REQUIRES: executable_test
7+ // REQUIRES: swift_in_compiler
8+ // REQUIRES: optimized_stdlib
9+ // REQUIRES: OS=macosx
10+ // REQUIRES: swift_feature_Embedded
11+
12+ import _Concurrency
13+
14+ func printCurrentTaskNilOrNonNil( ) {
15+ withUnsafeCurrentTask { task in
16+ print ( task == nil ? " nil " : " valid " )
17+ }
18+ }
19+
20+ public func test( ) async -> Int {
21+ printCurrentTaskNilOrNonNil ( )
22+ return 42
23+ }
24+
25+ @main
26+ struct Main {
27+ static func main( ) async {
28+ print ( " main " )
29+ // CHECK: main
30+
31+ printCurrentTaskNilOrNonNil ( )
32+ let t = Task {
33+ let x = await test ( )
34+ print ( x == 42 ? " 42 " : " ??? " )
35+ }
36+ await t. value
37+ // CHECK-NEXT: valid
38+ // CHECK-NEXT: valid
39+ // CHECK-NEXT: 42
40+ }
41+ }
You can’t perform that action at this time.
0 commit comments