@@ -9,10 +9,17 @@ func testNonConversions() async {
9
9
}
10
10
11
11
// Overloading
12
+ @available ( swift, deprecated: 4.0 , message: " synchronous is no fun " )
13
+ func overloadedSame( ) -> String { " synchronous " }
14
+
15
+ func overloadedSame( ) async -> String { " asynchronous " }
16
+
12
17
func overloaded( ) -> String { " synchronous " }
13
18
func overloaded( ) async -> Double { 3.14159 }
14
19
15
20
func testOverloadedSync( ) {
21
+ _ = overloadedSame ( ) // expected-warning{{synchronous is no fun}}
22
+
16
23
let _ = overloaded ( )
17
24
let fn = {
18
25
overloaded ( )
@@ -38,6 +45,8 @@ func testOverloadedSync() {
38
45
}
39
46
40
47
func testOverloadedAsync( ) async {
48
+ _ = await overloadedSame ( ) // no warning
49
+
41
50
let _ = await overloaded ( )
42
51
let _ = overloaded ( ) // expected-error{{call is 'async' but is not marked with 'await'}}
43
52
@@ -63,3 +72,14 @@ func testOverloadedAsync() async {
63
72
}
64
73
let _: Int = fn4 // expected-error{{value of type '() async -> ()'}}
65
74
}
75
+
76
+ func takesAsyncClosure( _ closure: ( ) async -> String ) -> Int { 0 }
77
+ func takesAsyncClosure( _ closure: ( ) -> String ) -> String { " " }
78
+
79
+ func testPassAsyncClosure( ) {
80
+ let a = takesAsyncClosure { await overloadedSame ( ) }
81
+ let _: Double = a // expected-error{{convert value of type 'Int'}}
82
+
83
+ let b = takesAsyncClosure { overloadedSame ( ) } // expected-warning{{synchronous is no fun}}
84
+ let _: Double = b // expected-error{{convert value of type 'String'}}
85
+ }
0 commit comments