Skip to content

Commit c046253

Browse files
committed
[IRGen] Emit swift_singletonEnum_destructiveInjectEnumTag
1 parent de177dc commit c046253

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

lib/IRGen/GenValueWitness.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -940,7 +940,7 @@ getDestructiveInjectEnumTagFunction(IRGenModule &IGM,
940940
!isRuntimeInstatiatedLayoutString(IGM, typeLayoutEntry))) {
941941
return nullptr;
942942
} else if (typeLayoutEntry->isSingleton()) {
943-
return nullptr;
943+
return IGM.getSingletonEnumDestructiveInjectEnumTagFn();
944944
} else if (!typeLayoutEntry->isFixedSize(IGM)) {
945945
if (typeLayoutEntry->isMultiPayloadEnum()) {
946946
return IGM.getMultiPayloadEnumGenericDestructiveInjectEnumTagFn();

test/Interpreter/layout_string_witnesses_dynamic.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,22 @@ func testResilientMultiPayloadEnumGenericInjectTag() {
646646

647647
testResilientMultiPayloadEnumGenericInjectTag()
648648

649+
@inline(never)
650+
func matchResilientSingletonEnumTag(_ x: ResilientSingletonEnum) -> Int {
651+
return switch x {
652+
case .nonEmpty: 0
653+
}
654+
}
655+
656+
func testResilientSingletonEnumGenericInjectTag() {
657+
let x = ResilientSingletonEnum.nonEmpty(SimpleClass(x: 23))
658+
659+
// CHECK: Enum case: 0
660+
print("Enum case: \(matchResilientSingletonEnumTag(x))")
661+
}
662+
663+
testResilientSingletonEnumGenericInjectTag()
664+
649665
#if os(macOS)
650666

651667
import Foundation

0 commit comments

Comments
 (0)