File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -2850,7 +2850,11 @@ void SILGenFunction::emitSwitchStmt(SwitchStmt *S) {
28502850 }
28512851
28522852 // If then we have an object, return it at +0.
2853+ // For opaque values, return at +1
28532854 if (subjectMV.getType ().isObject ()) {
2855+ if (subjectMV.getType ().isAddressOnly (F)) {
2856+ return {subjectMV.copy (*this , S), CastConsumptionKind::TakeAlways};
2857+ }
28542858 return {subjectMV, CastConsumptionKind::BorrowAlways};
28552859 }
28562860
Original file line number Diff line number Diff line change @@ -461,3 +461,20 @@ class TestGeneric<T> {
461461// CHECK: unwind
462462// CHECK-LABEL: } // end sil function '$s20opaque_values_silgen11TestGenericC08borrowedE0xvr'
463463
464+ // CHECK-LABEL: sil hidden [ossa] @$s20opaque_values_silgen8TestEnumO5_codeSivg :
465+ // CHECK: bb0(%0 : @guaranteed $TestEnum<T>):
466+ // CHECK: [[COPY:%.*]] = copy_value %0 : $TestEnum<T>
467+ // CHECK: switch_enum [[COPY]] : $TestEnum<T>, case #TestEnum.invalidValue!enumelt: bb1
468+ // CHECK: bb1([[VAL:%.*]] : @owned $Any):
469+ // CHECK: destroy_value [[VAL]] : $Any
470+ // CHECK-LABEL: } // end sil function '$s20opaque_values_silgen8TestEnumO5_codeSivg'
471+ enum TestEnum < T> {
472+ case invalidValue( Any )
473+
474+ var _code : Int {
475+ switch self {
476+ case . invalidValue: return 4866
477+ }
478+ }
479+ }
480+
You can’t perform that action at this time.
0 commit comments