- Notifications
You must be signed in to change notification settings - Fork 10.5k
/
Copy pathconcurrent_value_inference.swift
143 lines (114 loc) · 3.6 KB
/
concurrent_value_inference.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
// RUN: %target-swift-frontend -enable-library-evolution -strict-concurrency=complete %s -emit-sil -o /dev/null -verify
// RUN: %target-swift-frontend -enable-library-evolution -strict-concurrency=complete %s -emit-sil -o /dev/null -verify -enable-upcoming-feature RegionBasedIsolation
// REQUIRES: concurrency
// REQUIRES: swift_feature_RegionBasedIsolation
classC1{} // expected-note {{class 'C1' does not conform to the 'Sendable' protocol}}
finalclassC2:Sendable{}
structS1{
varx:Int
vars:String
varc:C2
}
enumE1{ // expected-note {{consider making enum 'E1' conform to the 'Sendable' protocol}}{{9-9=: Sendable}}
case base
indirectcase nested(E1)
}
enumE2{
case s1(S1)
case c2(C2)
}
structGS1<T>{}
structGS2<T>{ // expected-note {{consider making generic struct 'GS2' conform to the 'Sendable' protocol}}
varstorage:T
}
func acceptCV<T:Sendable>(_:T){}
// Example that was triggering circular dependencies.
structSignature{}
structData{}
structBlockInfo{}
structBitcode{ // expected-note {{consider making struct 'Bitcode' conform to the 'Sendable' protocol}}
letsignature:Signature
letelements:[BitcodeElement]
letblockInfo:[UInt64:BlockInfo]
}
enumBitcodeElement{
structBlock{
varid:UInt64
varelements:[BitcodeElement]
}
structRecord{
enumPayload{
case none
case array([UInt64])
case char6String(String)
case blob(Data)
}
varid:UInt64
varfields:[UInt64]
varpayload:Payload
}
case block(Block)
case record(Record)
}
// Public structs and enums do not get implicit Sendable unless they
// are frozen.
publicstructPublicStruct{ // expected-note {{consider making struct 'PublicStruct' conform to the 'Sendable' protocol}}
vari:Int
}
publicenumPublicEnum{ // expected-note {{consider making enum 'PublicEnum' conform to the 'Sendable' protocol}}
case some
}
@frozenpublicstructFrozenPublicStruct{
vari:Int
}
@frozenpublicenumFrozenPublicEnum{
case some
}
structHasFunctions{
vartfp:@convention(thin)()->Void
varcfp:@convention(c)()->Void
}
@available(SwiftStdlib 5.1,*)
@globalActor
actorMyGlobalActor{
staticletshared=MyGlobalActor()
}
@available(SwiftStdlib 5.1,*)
@MyGlobalActor
classC3{}
@available(SwiftStdlib 5.1,*)
classC4:C3{}
// Make Sendable unavailable, but be sure not to diagnose it.
structS2{
varc1:C1
}
@available(*, unavailable)
extensionS2:Sendable{}
@available(SwiftStdlib 5.1,*)
func testCV(
c1:C1, c2:C2, c3:C3, c4:C4, s1:S1, e1:E1, e2:E2,
gs1:GS1<Int>, gs2:GS2<Int>,
bc:Bitcode, ps:PublicStruct, pe:PublicEnum,
fps:FrozenPublicStruct, fpe:FrozenPublicEnum,
hf:HasFunctions
){
acceptCV(c1) // expected-warning {{type 'C1' does not conform to the 'Sendable' protocol}}
acceptCV(c2)
acceptCV(c3)
acceptCV(c4)
acceptCV(s1)
acceptCV(e1) // expected-warning {{type 'E1' does not conform to the 'Sendable'}}
acceptCV(e2)
acceptCV(gs1)
acceptCV(gs2) // expected-warning {{type 'GS2<Int>' does not conform to the 'Sendable' protocol}}
// Not available due to recursive conformance dependencies.
acceptCV(bc) // expected-warning {{type 'Bitcode' does not conform to the 'Sendable' protocol}}
// Not available due to "public".
acceptCV(ps) // expected-warning {{type 'PublicStruct' does not conform to the 'Sendable' protocol}}
acceptCV(pe) // expected-warning {{type 'PublicEnum' does not conform to the 'Sendable' protocol}}
// Public is okay when also @frozen.
acceptCV(fps)
acceptCV(fpe)
// Thin and C function types are Sendable.
acceptCV(hf)
}