@@ -3508,6 +3508,33 @@ bb0(%0 : $VV):
3508
3508
return %26 : $()
3509
3509
}
3510
3510
3511
+ sil @any_to_object : $@convention(thin) <τ_0_0> (@in_guaranteed τ_0_0) -> @owned AnyObject
3512
+
3513
+ // CHECK-LABEL: sil @dont_crash_when_propagating_existentials
3514
+ // CHECK: [[EM:%[0-9]+]] = init_existential_metatype %0
3515
+ // CHECK: [[S:%[0-9]+]] = alloc_stack $Any
3516
+ // CHECK: [[M:%[0-9]+]] = open_existential_metatype [[EM]]
3517
+ // CHECK: [[E:%[0-9]+]] = init_existential_addr [[S]]
3518
+ // CHECK: store [[M]] to [[E]]
3519
+ // CHECK: apply {{%[0-9]+}}<(@opened("5F99B72C-EC40-11EA-9534-8C8590A6A134") AnyObject).Type>([[E]])
3520
+ // CHECK: } // end sil function 'dont_crash_when_propagating_existentials'
3521
+ sil @dont_crash_when_propagating_existentials : $@convention(thin) () -> @owned AnyObject {
3522
+ bb0:
3523
+ %0 = metatype $@thick C.Type
3524
+ %1 = init_existential_metatype %0 : $@thick C.Type, $@thick AnyObject.Type
3525
+ %3 = alloc_stack $Any, let, name "object"
3526
+ %4 = open_existential_metatype %1 : $@thick AnyObject.Type to $@thick (@opened("5F99B72C-EC40-11EA-9534-8C8590A6A134") AnyObject).Type
3527
+ %5 = init_existential_addr %3 : $*Any, $(@opened("5F99B72C-EC40-11EA-9534-8C8590A6A134") AnyObject).Type
3528
+ store %4 to %5 : $*@thick (@opened("5F99B72C-EC40-11EA-9534-8C8590A6A134") AnyObject).Type
3529
+ %7 = open_existential_addr immutable_access %3 : $*Any to $*@opened("5F9F1B04-EC40-11EA-9534-8C8590A6A134") Any
3530
+ %8 = function_ref @any_to_object : $@convention(thin) <τ_0_0> (@in_guaranteed τ_0_0) -> @owned AnyObject
3531
+ %9 = apply %8<@opened("5F9F1B04-EC40-11EA-9534-8C8590A6A134") Any>(%7) : $@convention(thin) <τ_0_0> (@in_guaranteed τ_0_0) -> @owned AnyObject
3532
+ destroy_addr %3 : $*Any
3533
+ dealloc_stack %3 : $*Any
3534
+ return %9 : $AnyObject
3535
+ }
3536
+
3537
+
3511
3538
// CHECK-LABEL: sil @remove_unused_alloc_ref
3512
3539
// CHECK-NEXT: bb0
3513
3540
// CHECK-NEXT: %0 = tuple ()
0 commit comments