@@ -478,6 +478,42 @@ enum TestEnum<T> {
478
478
}
479
479
}
480
480
481
+ public enum EnumWithTwoSameAddressOnlyPayloads < T> {
482
+ case nope
483
+ case yes( T )
484
+ case and( T )
485
+
486
+ // CHECK-LABEL: sil [ossa] @EnumWithTwoSameAddressOnlyPayloads_getPayload : {{.*}} {
487
+ // CHECK: {{bb[0-9]+}}([[INSTANCE:%[^,]+]] :
488
+ // CHECK: [[RESULT_STORAGE:%[^,]+]] = alloc_stack $T
489
+ // CHECK: [[COPY:%[^,]+]] = copy_value [[INSTANCE]]
490
+ // CHECK: switch_enum [[COPY]] : $EnumWithTwoSameAddressOnlyPayloads<T>,
491
+ // CHECK-SAME: case #EnumWithTwoSameAddressOnlyPayloads.nope!enumelt: {{bb[0-9]+}},
492
+ // CHECK-SAME: case #EnumWithTwoSameAddressOnlyPayloads.yes!enumelt: [[YES_BLOCK:bb[0-9]+]],
493
+ // CHECK-SAME: case #EnumWithTwoSameAddressOnlyPayloads.and!enumelt: [[AND_BLOCK:bb[0-9]+]]
494
+ // CHECK: [[YES_BLOCK]]([[YES_VALUE:%[^,]+]] :
495
+ // CHECK: [[YES_LIFETIME:%[^,]+]] = begin_borrow [lexical] [[YES_VALUE]]
496
+ // CHECK: [[YES_COPY:%[^,]+]] = copy_value [[YES_LIFETIME]]
497
+ // CHECK: store [[YES_COPY]] to [init] [[RESULT_STORAGE]]
498
+ // CHECK: [[AND_BLOCK]]([[AND_VALUE:%[^,]+]] :
499
+ // CHECK: [[AND_LIFETIME:%[^,]+]] = begin_borrow [lexical] [[AND_VALUE]]
500
+ // CHECK: [[AND_COPY:%[^,]+]] = copy_value [[AND_LIFETIME]]
501
+ // CHECK: store [[AND_COPY]] to [init] [[RESULT_STORAGE]]
502
+ // CHECK-LABEL: } // end sil function 'EnumWithTwoSameAddressOnlyPayloads_getPayload'
503
+ public var getPayload : T ? {
504
+ @_silgen_name ( " EnumWithTwoSameAddressOnlyPayloads_getPayload " )
505
+ get {
506
+ switch self {
507
+ case . nope:
508
+ return nil
509
+ case . yes( let t) , . and( let t) :
510
+ return t
511
+ }
512
+ }
513
+ }
514
+ }
515
+
516
+
481
517
// Verify exit block arguments are ordered correctly.
482
518
//
483
519
// CHECK-LABEL: sil private [ossa] @$s20opaque_values_silgen19duplicate_with_int49condition5valueSi_S2ix_xttSb_xtlFSi_S2ix_xttyXEfU_ : {{.*}} {
0 commit comments