@@ -203,6 +203,41 @@ func passesClosureWithReabstractionToRethrowing(count: Int) {
203
203
}
204
204
205
205
206
+ // CHECK-LABEL: sil hidden [ossa] @$s12typed_throws13throwAndCatchyyyyxYKXExYKs5ErrorRzlF : $@convention(thin) <E where E : Error> (@guaranteed @noescape @callee_guaranteed @substituted <τ_0_0> () -> @error_indirect τ_0_0 for <E>) -> @error_indirect E {
207
+ func throwAndCatch< E: Error > ( _ body: ( ) throws ( E ) -> Void ) throws ( E) {
208
+ do {
209
+ // CHECK: [[OUTER_ERR:%.*]] = alloc_stack $E
210
+ // CHECK: try_apply [[FN:%.*]]([[ERROR_ARG:%.*]]) : $@noescape @callee_guaranteed @substituted <τ_0_0> () -> @error_indirect τ_0_0 for <E>, normal [[NORMAL_BB:bb.*]], error [[ERROR_BB:bb.*]] //
211
+ try body ( )
212
+ } catch {
213
+ // CHECK: [[ERROR_BB]]:
214
+ // CHECK-NEXT: copy_addr [take] [[ERROR_ARG]] to [init] [[OUTER_ERR]] : $*E
215
+ // CHECK: dealloc_stack [[ERROR_ARG]] : $*E
216
+ print ( error)
217
+ }
218
+ }
219
+
220
+ enum HomeworkError : Error {
221
+ case dogAteIt
222
+ case forgot
223
+ }
224
+
225
+ // CHECK-LABEL: sil hidden [ossa] @$s12typed_throws25throwAndPatternMatchCatchyyyyxYKXExYKs5ErrorRzlF : $@convention(thin) <E where E : Error> (@guaranteed @noescape @callee_guaranteed @substituted <τ_0_0> () -> @error_indirect τ_0_0 for <E>) -> @error_indirect E {
226
+ func throwAndPatternMatchCatch< E: Error > ( _ body: ( ) throws ( E ) -> Void ) throws ( E) {
227
+ do {
228
+ // CHECK: [[OUTER_ERR:%.*]] = alloc_stack $E
229
+ // CHECK: try_apply [[FN:%.*]]([[ERROR_ARG:%.*]]) : $@noescape @callee_guaranteed @substituted <τ_0_0> () -> @error_indirect τ_0_0 for <E>, normal [[NORMAL_BB:bb.*]], error [[ERROR_BB:bb.*]] //
230
+ try body ( )
231
+ } catch let he as HomeworkError where he == . dogAteIt {
232
+ // CHECK: copy_addr [take] [[ERROR_ARG]] to [init] [[OUTER_ERR]] : $*E
233
+ // CHECK: [[HOMEWORK_ERR:%.*]] = alloc_stack $HomeworkError
234
+ // CHECK: checked_cast_addr_br copy_on_success E in [[OUTER_ERR]] : $*E to HomeworkError in [[HOMEWORK_ERR]] : $*HomeworkError
235
+
236
+ // bad dog
237
+ } catch {
238
+ }
239
+ }
240
+
206
241
// CHECK-LABEL: sil_vtable MySubclass {
207
242
// CHECK-NEXT: #MyClass.init!allocator: <E where E : Error> (MyClass.Type) -> (() throws(E) -> ()) throws(E) -> MyClass : @$s12typed_throws10MySubclassC4bodyACyyxYKXE_txYKcs5ErrorRzlufC [override]
208
243
// CHECK-NEXT: #MyClass.f: (MyClass) -> () throws -> () : @$s12typed_throws10MySubclassC1fyyAA0C5ErrorOYKFAA0C5ClassCADyyKFTV [override]
0 commit comments