File tree Expand file tree Collapse file tree 1 file changed +49
-0
lines changed
Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Original file line number Diff line number Diff line change 1+ // RUN: %empty-directory(%t)
2+ // RUN: %target-build-swift -Xfrontend -disable-availability-checking -O %s -o %t/main
3+ // RUN: %target-codesign %t/main
4+ // RUN: %target-run %t/main | %FileCheck %s
5+
6+ // REQUIRES: executable_test
7+ // REQUIRES: concurrency
8+
9+ // CHECK: Setting field Field(rawValue: "fxxxxxxx/0")
10+ // CHECK: Setting field Field(rawValue: "fxxxxxxx/1")
11+ // CHECK: Setting field Field(rawValue: "fxxxxxxx/2")
12+ // CHECK: Setting field Field(rawValue: "fxxxxxxx/3")
13+
14+ internal struct Field : Equatable , Hashable , Sendable {
15+ internal var rawValue : String
16+
17+ internal static var c0 : Field { Field ( rawValue: " fxxxxxxx/0 " ) }
18+ internal static var c1 : Field { Field ( rawValue: " fxxxxxxx/1 " ) }
19+ internal static var c2 : Field { Field ( rawValue: " fxxxxxxx/2 " ) }
20+ internal static var c3 : Field { Field ( rawValue: " fxxxxxxx/3 " ) }
21+
22+ internal static func c( _ c: Int ) -> Field {
23+ switch c {
24+ case 0 : return self . c0
25+ case 1 : return self . c1
26+ case 2 : return self . c2
27+ case 3 : return self . c3
28+ default :
29+ preconditionFailure ( " Only 0..<4 are valid " )
30+ }
31+ }
32+ }
33+
34+ internal actor A {
35+ @inline ( never)
36+ internal func set( _ field: Field ) async throws {
37+ print ( " Setting field \( field) " )
38+ }
39+ }
40+
41+ func doit( ) async throws {
42+ let a = A ( )
43+ for c in 0 ..< Int ( 4 ) {
44+ try await Task . sleep ( nanoseconds: 50_000_000 )
45+ try await a. set ( . c( c) )
46+ }
47+ }
48+
49+ try await doit ( )
You can’t perform that action at this time.
0 commit comments