File tree Expand file tree Collapse file tree 2 files changed +52
-0
lines changed
Expand file tree Collapse file tree 2 files changed +52
-0
lines changed Original file line number Diff line number Diff line change 1+ #ifndef Delegate_h
2+ #define Delegate_h
3+
4+ @import Foundation;
5+
6+ @interface Request : NSObject
7+
8+ @end
9+
10+ @interface Delegate : NSObject
11+
12+ - (void )makeRequest1 : (Request * _Nonnull)request completionHandler : (void (^ _Nullable)(void ))handler ;
13+
14+ - (void )makeRequest2 : (NSObject * _Nonnull)request completionHandler : (void (^ _Nullable)(void ))handler ;
15+
16+ - (void )makeRequest3 : (Request * _Nullable)request completionHandler : (void (^ _Nullable)(void ))handler ;
17+
18+ @end
19+
20+
21+ #endif
Original file line number Diff line number Diff line change 1+ // RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -enable-experimental-concurrency -typecheck -verify -import-objc-header %S/Inputs/Delegate.h %s
2+
3+ // REQUIRES: objc_interop
4+
5+
6+ // overload resolution should pick sync version in a sync context
7+ func syncContext( ) {
8+ let r = Request ( )
9+ let d = Delegate ( )
10+ d. makeRequest1 ( r) // NOTE: this use to trigger an overload resolution error, see SR-13760
11+ d. makeRequest2 ( r)
12+ d. makeRequest3 ( r)
13+ }
14+
15+ // overload resolution should pick async version in an async context
16+ func asyncNoAwait( ) async {
17+ let r = Request ( )
18+ let d = Delegate ( )
19+ d. makeRequest1 ( r) // expected-error {{call is 'async' but is not marked with 'await'}}
20+ d. makeRequest2 ( r) // expected-error {{call is 'async' but is not marked with 'await'}}
21+ d. makeRequest3 ( r) // expected-error {{call is 'async' but is not marked with 'await'}}
22+ }
23+
24+
25+ func asyncWithAwait( ) async {
26+ let r = Request ( )
27+ let d = Delegate ( )
28+ await d. makeRequest1 ( r)
29+ await d. makeRequest2 ( r)
30+ await d. makeRequest3 ( r)
31+ }
You can’t perform that action at this time.
0 commit comments