@@ -56,6 +56,16 @@ protocol P {
56
56
func doSomething()
57
57
}
58
58
59
+ sil @initP : $@convention(thin) () -> @owned P
60
+ sil @transferP : $@async @convention(thin) (@guaranteed P) -> ()
61
+
62
+ protocol PAnyObject : AnyObject {}
63
+
64
+ sil @initPAnyObject : $@convention(thin) () -> @owned PAnyObject
65
+ sil @initPAnyObjectOptional : $@convention(thin) () -> @owned Optional<PAnyObject>
66
+ sil @transferPAnyObject : $@async @convention(thin) (@guaranteed PAnyObject) -> ()
67
+ sil @usePAnyObjectWeak : $@convention(thin) (@guaranteed @sil_weak Optional<PAnyObject>) -> ()
68
+
59
69
/////////////////
60
70
// MARK: Tests //
61
71
/////////////////
97
107
return %9999 : $()
98
108
}
99
109
100
- sil @initP : $@convention(thin) () -> @owned P
101
- sil @transferP : $@async @convention(thin) (@guaranteed P) -> ()
102
-
103
110
sil [ossa] @open_existential_value_test : $@async @convention(thin) () -> () {
104
111
bb0:
105
112
%f = function_ref @initP : $@convention(thin) () -> @owned P
@@ -118,3 +125,25 @@ bb0:
118
125
%9999 = tuple ()
119
126
return %9999 : $()
120
127
}
128
+
129
+ sil [ossa] @weak_copy_value_test : $@async @convention(thin) () -> () {
130
+ bb0:
131
+ %f = function_ref @initPAnyObjectOptional : $@convention(thin) () -> @owned Optional<PAnyObject>
132
+ %p = apply %f() : $@convention(thin) () -> @owned Optional<PAnyObject>
133
+
134
+ %pBorrowed = begin_borrow %p : $Optional<PAnyObject>
135
+ %pExt = unchecked_enum_data %pBorrowed : $Optional<PAnyObject>, #Optional.some!enumelt
136
+ %transferP = function_ref @transferPAnyObject : $@async @convention(thin) (@guaranteed PAnyObject) -> ()
137
+ apply [caller_isolation=nonisolated] [callee_isolation=global_actor] %transferP(%pExt) : $@async @convention(thin) (@guaranteed PAnyObject) -> () // expected-warning {{transferring value of non-Sendable type 'any PAnyObject' from nonisolated context to global actor '<null>'-isolated context}}
138
+
139
+ %w = weak_copy_value %pBorrowed : $Optional<PAnyObject>
140
+ %weakFunc = function_ref @usePAnyObjectWeak : $@convention(thin) (@guaranteed @sil_weak Optional<PAnyObject>) -> ()
141
+ apply %weakFunc(%w) : $@convention(thin) (@guaranteed @sil_weak Optional<PAnyObject>) -> () // expected-note {{access here could race}}
142
+ destroy_value %w : $@sil_weak Optional<PAnyObject>
143
+
144
+ end_borrow %pBorrowed : $Optional<PAnyObject>
145
+ destroy_value %p : $Optional<PAnyObject>
146
+
147
+ %9999 = tuple ()
148
+ return %9999 : $()
149
+ }
0 commit comments