1
- // async main is nested deeper in protocols than sync, should use sync (always)
2
- // sync main is nested deeper in protocols than async, use async if supported
3
- // async and sync are same level, use async if supported
4
-
5
- // async main is nested in the protocol chain from `MyMain`
6
- // Always choose Sync overload
7
- // RUN: %target-swift-frontend -target x86_64-apple-macosx10.9 -DASYNC_NESTED -DINHERIT_SYNC -typecheck -dump-ast -parse-as-library %s | %FileCheck %s --check-prefix=CHECK-IS-SYNC
8
- // RUN: %target-swift-frontend -target x86_64-apple-macosx11.0 -DASYNC_NESTED -DINHERIT_SYNC -typecheck -dump-ast -parse-as-library %s | %FileCheck %s --check-prefix=CHECK-IS-SYNC
9
-
10
- // sync main is deeper in the protocol chain from `MyMain`
11
- // Choose async when available
12
- // RUN: %target-swift-frontend -target x86_64-apple-macosx10.9 -typecheck -dump-ast -parse-as-library %s | %FileCheck %s --check-prefix=CHECK-IS-SYNC
13
- // RUN: %target-swift-frontend -target x86_64-apple-macosx11.0 -typecheck -dump-ast -parse-as-library %s | %FileCheck %s --check-prefix=CHECK-IS-ASYNC
14
-
15
- // sync and async main are at same level (In MainProtocol) to `MyMain`.
16
- // Choose async when available
17
- // RUN: %target-swift-frontend -target x86_64-apple-macosx10.9 -DBOTH -DINHERIT_SYNC -typecheck -dump-ast -parse-as-library %s | %FileCheck %s --check-prefix=CHECK-IS-SYNC
18
- // RUN: %target-swift-frontend -target x86_64-apple-macosx11.9 -DBOTH -DINHERIT_SYNC -typecheck -dump-ast -parse-as-library %s | %FileCheck %s --check-prefix=CHECK-IS-ASYNC
19
-
20
- // async main is the only option on the protocol chain
21
- // Choose async if we support it, error otherwise
22
- // RUN: not %target-swift-frontend -target x86_64-apple-macosx10.9 -DASYNC_NESTED -typecheck -dump-ast -parse-as-library %s 2>&1 | %FileCheck %s --check-prefix=CHECK-IS-ERROR
23
- // RUN: %target-swift-frontend -target x86_64-apple-macosx11.9 -DASYNC_NESTED -typecheck -dump-ast -parse-as-library %s | %FileCheck %s --check-prefix=CHECK-IS-ASYNC
24
-
25
- // sync main is the only option on the protocol chain
26
- // Always choose sync
27
- // RUN: %target-swift-frontend -target x86_64-apple-macosx10.9 -DINHERIT_SYNC -typecheck -dump-ast -parse-as-library %s | %FileCheck %s --check-prefix=CHECK-IS-SYNC
28
- // RUN: %target-swift-frontend -target x86_64-apple-macosx11.9 -DINHERIT_SYNC -typecheck -dump-ast -parse-as-library %s | %FileCheck %s --check-prefix=CHECK-IS-SYNC
29
-
30
- // No synchronous, choose async if we support it, error otherwise
31
- // RUN: not %target-swift-frontend -target x86_64-apple-macosx10.9 -DNO_SYNC -typecheck -dump-ast -parse-as-library %s 2>&1 | %FileCheck %s --check-prefix=CHECK-IS-ERROR
32
- // RUN: %target-swift-frontend -target x86_64-apple-macosx11.9 -DNO_SYNC -typecheck -dump-ast -parse-as-library %s | %FileCheck %s --check-prefix=CHECK-IS-ASYNC
33
-
34
- // No asynchronous, choose sync
35
- // RUN: %target-swift-frontend -target x86_64-apple-macosx10.9 -DNO_ASYNC -typecheck -dump-ast -parse-as-library %s | %FileCheck %s --check-prefix=CHECK-IS-SYNC
36
- // RUN: %target-swift-frontend -target x86_64-apple-macosx11.9 -DNO_ASYNC -typecheck -dump-ast -parse-as-library %s | %FileCheck %s --check-prefix=CHECK-IS-SYNC
37
-
38
- // No main functions
39
- // RUN: not %target-swift-frontend -target x86_64-apple-macosx10.9 -DNO_SYNC -DNO_ASYNC -typecheck -dump-ast -parse-as-library %s 2>&1 | %FileCheck %s --check-prefix=CHECK-IS-ERROR
40
- // RUN: not %target-swift-frontend -target x86_64-apple-macosx11.9 -DNO_SYNC -DNO_ASYNC -typecheck -dump-ast -parse-as-library %s 2>&1 | %FileCheck %s --check-prefix=CHECK-IS-ERROR-ASYNC
1
+ // Non-apple platforms don't need to worry about the version number as much
2
+ // because they can pull in the concurrency libraries with the swift
3
+ // installation.
4
+
5
+ // async main is nested deeper in protocols than sync, use sync
6
+ // sync main is nested deeper in protocols than async, use async
7
+ // async and sync are same level, use async
41
8
42
9
// REQUIRES: concurrency
10
+ // UNSUPPORTED: VENDOR=apple
11
+
12
+ // Async is deeper in the protocol chain from `MyMain`, use sync
13
+ // RUN: %target-swift-frontend -DASYNC_NESTED -DINHERIT_SYNC -typecheck -dump-ast -parse-as-library %s | %FileCheck %s --check-prefix=CHECK-IS-SYNC
14
+
15
+ // Sync is deeper in the protocol chain from `MyMain`, use async
16
+ // RUN: %target-swift-frontend -typecheck -dump-ast -parse-as-library %s | %FileCheck %s --check-prefix=CHECK-IS-ASYNC
17
+
18
+ // Async and sync are the same level, use async
19
+ // RUN: %target-swift-frontend -DBOTH -DINHERIT_SYNC -typecheck -dump-ast -parse-as-library %s | %FileCheck %s --check-prefix=CHECK-IS-ASYNC
43
20
44
21
#if ASYNC_NESTED
45
22
protocol AsyncMainProtocol { }
@@ -59,14 +36,12 @@ extension MainProtocol {
59
36
#if NO_ASYNC
60
37
#else
61
38
extension AsyncMainProtocol {
62
- @available ( macOS 10 . 15 , * )
63
39
static func main( ) async { }
64
40
}
65
41
#endif
66
42
67
43
#if BOTH
68
44
extension MainProtocol {
69
- @available ( macOS 10 . 15 , * )
70
45
static func main( ) async { }
71
46
}
72
47
#endif
@@ -79,10 +54,13 @@ extension MainProtocol {
79
54
#endif
80
55
81
56
82
- // CHECK-IS-SYNC-LABEL: (func_decl implicit "$main()" interface type='(MyMain.Type) -> () -> ()'
57
+
58
+ // CHECK-IS-SYNC-LABEL: "MyMain" interface type='MyMain.Type'
59
+ // CHECK-IS-SYNC: (func_decl implicit "$main()" interface type='(MyMain.Type) -> () -> ()'
83
60
// CHECK-IS-SYNC: (declref_expr implicit type='(MyMain.Type) -> () -> ()'
84
61
85
- // CHECK-IS-ASYNC-LABEL: (func_decl implicit "$main()" interface type='(MyMain.Type) -> () async -> ()'
62
+ // CHECK-IS-ASYNC-LABEL: "MyMain" interface type='MyMain.Type'
63
+ // CHECK-IS-ASYNC: (func_decl implicit "$main()" interface type='(MyMain.Type) -> () async -> ()'
86
64
// CHECK-IS-ASYNC: (declref_expr implicit type='(MyMain.Type) -> () async -> ()'
87
65
88
66
// CHECK-IS-ERROR: error: 'MyMain' is annotated with @main and must provide a main static function of type () -> Void or () throws -> Void
0 commit comments