Skip to content

Commit 90a69bd

Browse files
committed
Adding expected resolution test case
The test case is the situation that causes problems. Specifically, for `Config1`, you would expect the `main()` function where `Configuration == Config1` to be selected, but because we favored asynchronous main functions, we would select the one from the default `App` extension, which is bad.
1 parent 02ba725 commit 90a69bd

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// RUN: %target-swift-frontend -disable-availability-checking -D CONFIG1 -dump-ast -parse-as-library %s | %FileCheck %s --check-prefix=CHECK-CONFIG1
2+
// RUN: %target-swift-frontend -disable-availability-checking -D CONFIG2 -dump-ast -parse-as-library %s | %FileCheck %s --check-prefix=CHECK-CONFIG2
3+
// RUN: %target-swift-frontend -disable-availability-checking -D CONFIG3 -dump-ast -parse-as-library %s | %FileCheck %s --check-prefix=CHECK-CONFIG3
4+
5+
// REQUIRES: concurrency
6+
7+
protocol AppConfiguration { }
8+
9+
struct Config1: AppConfiguration {}
10+
struct Config2: AppConfiguration {}
11+
struct Config3: AppConfiguration {}
12+
13+
protocol App {
14+
associatedtype Configuration: AppConfiguration
15+
}
16+
17+
extension App where Configuration == Config1 {
18+
// CHECK-CONFIG1: (func_decl implicit "$main()" interface type='(MainType.Type) -> () -> ()'
19+
// CHECK-CONFIG1: where_clause_main_resolution.swift:[[# @LINE+1 ]]
20+
static func main() { }
21+
}
22+
23+
extension App where Configuration == Config2 {
24+
// CHECK-CONFIG2: (func_decl implicit "$main()" interface type='(MainType.Type) -> () async -> ()'
25+
// CHECK-CONFIG2: where_clause_main_resolution.swift:[[# @LINE+1 ]]
26+
static func main() async { }
27+
}
28+
29+
extension App {
30+
// CHECK-CONFIG3: (func_decl implicit "$main()" interface type='(MainType.Type) -> () async -> ()'
31+
// CHECK-CONFIG3: where_clause_main_resolution.swift:[[# @LINE+1 ]]
32+
static func main() async { }
33+
}
34+
35+
@main
36+
struct MainType : App {
37+
38+
#if CONFIG1
39+
typealias Configuration = Config1
40+
#elseif CONFIG2
41+
typealias Configuration = Config2
42+
#elseif CONFIG3
43+
typealias Configuration = Config3
44+
#endif
45+
}

0 commit comments

Comments
 (0)