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
418
429// 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
4320
4421#if ASYNC_NESTED
4522protocol AsyncMainProtocol { }
@@ -59,14 +36,12 @@ extension MainProtocol {
5936#if NO_ASYNC
6037#else
6138extension AsyncMainProtocol {
62- @available ( macOS 10 . 15 , * )
6339 static func main( ) async { }
6440}
6541#endif
6642
6743#if BOTH
6844extension MainProtocol {
69- @available ( macOS 10 . 15 , * )
7045 static func main( ) async { }
7146}
7247#endif
@@ -79,10 +54,13 @@ extension MainProtocol {
7954#endif
8055
8156
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) -> () -> ()'
8360// CHECK-IS-SYNC: (declref_expr implicit type='(MyMain.Type) -> () -> ()'
8461
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 -> ()'
8664// CHECK-IS-ASYNC: (declref_expr implicit type='(MyMain.Type) -> () async -> ()'
8765
8866// 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